-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make permissions matrix-auth-3.0+ compatible
by adding support to explicitly assign permissions to groups or users. With https://github.com/jenkinsci/matrix-auth-plugin/releases/tag/matrix-auth-3.0 ambiguous permissions will show a warning.
- Loading branch information
1 parent
e8d87c1
commit 280e1f2
Showing
8 changed files
with
249 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 24 additions & 4 deletions
28
job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/Folder/authorization.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
// gives permission for the special authenticated group to create jobs in the folder | ||
// gives permission to create jobs in the folder | ||
folder('example-1') { | ||
authorization { | ||
permission('hudson.model.Item.Create:authenticated') | ||
// requires matrix-auth > 3.0 | ||
permission('GROUP:hudson.model.Item.Create:group1') | ||
permission('USER:hudson.model.Item.Create:user1') | ||
groupPermission('hudson.model.Item.Create', 'group2') | ||
userPermission('hudson.model.Item.Create', 'user2') | ||
} | ||
} | ||
|
||
// gives discover permission for the special anonymous user | ||
// gives discover permission | ||
folder('example-2') { | ||
authorization { | ||
permission('hudson.model.Item.Discover', 'anonymous') | ||
// requires matrix-auth > 3.0 | ||
permission('USER:hudson.model.Item.Discover:anonymous') | ||
userPermission('hudson.model.Item.Discover', 'anonymous') | ||
} | ||
} | ||
|
||
// gives all permissions to the special anonymous user | ||
// gives all permissions | ||
folder('example-3') { | ||
authorization { | ||
permissionAll('anonymous') | ||
// requires matrix-auth > 3.0 | ||
userPermissionAll('user1') | ||
groupPermissionAll('group1') | ||
} | ||
} | ||
|
||
// gives the hudson.model.Item.Discover and hudson.model.Item.Create permission to jill | ||
// gives the hudson.model.Item.Discover and hudson.model.Item.Create permissions | ||
folder('example-4') { | ||
authorization { | ||
permissions('jill', [ | ||
'hudson.model.Item.Create', | ||
'hudson.model.Item.Discover' | ||
]) | ||
// requires matrix-auth > 3.0 | ||
userPermissions('user1', [ | ||
'hudson.model.Item.Create', | ||
'hudson.model.Item.Discover' | ||
]) | ||
groupPermissions('group1', [ | ||
'hudson.model.Item.Create', | ||
'hudson.model.Item.Discover' | ||
]) | ||
} | ||
} |
26 changes: 22 additions & 4 deletions
26
job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/Job/authorization.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,50 @@ | ||
// add a permission for the special authenticated group to see the workspace of the job | ||
// add group permissions to see the workspace of the job | ||
job('example-1') { | ||
authorization { | ||
permission('hudson.model.Item.Workspace:authenticated') | ||
// requires matrix-auth > 3.0 | ||
permission('GROUP:hudson.model.Item.Workspace:group1') | ||
groupPermission('hudson.model.Item.Workspace', 'group2') | ||
} | ||
} | ||
|
||
// adds the build permission for the special anonymous user | ||
// adds the build permission to users | ||
job('example-2') { | ||
authorization { | ||
permission('hudson.model.Item.Build', 'anonymous') | ||
// requires matrix-auth > 3.0 | ||
permission('USER:hudson.model.Item.Build:user1') | ||
userPermission('hudson.model.Item.Build', 'user2') | ||
} | ||
} | ||
|
||
// add all permissions for user joe, blocking inheritance of the global | ||
// add all permissions to users or groups, blocking inheritance of the global | ||
// authorization matrix | ||
job('example-3') { | ||
authorization { | ||
permissionAll('joe') | ||
blocksInheritance() | ||
// requires matrix-auth > 3.0 | ||
userPermissionAll('user1') | ||
groupPermissionAll('group1') | ||
} | ||
} | ||
|
||
// gives the hudson.model.Item.Discover and hudson.model.Item.Create permission to jill | ||
// gives the hudson.model.Item.Discover and hudson.model.Item.Create permission to user resp. groups | ||
job('example-4') { | ||
authorization { | ||
permissions('jill', [ | ||
'hudson.model.Item.Create', | ||
'hudson.model.Item.Discover' | ||
]) | ||
// requires matrix-auth > 3.0 | ||
userPermissions('user1', [ | ||
'hudson.model.Item.Create', | ||
'hudson.model.Item.Discover' | ||
]) | ||
groupPermissions('group1', [ | ||
'hudson.model.Item.Create', | ||
'hudson.model.Item.Discover' | ||
]) | ||
} | ||
} |
10 changes: 8 additions & 2 deletions
10
...main/docs/examples/javaposse/jobdsl/dsl/helpers/JobAuthorizationContext/permission.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
// add a permission for the special authenticated group to see the workspace of the job | ||
// add permission to see the workspace of the job | ||
job('example-1') { | ||
authorization { | ||
permission('hudson.model.Item.Workspace:authenticated') | ||
// requires matrix-auth > 3.0 | ||
permission('GROUP:hudson.model.Item.Workspace:group1') | ||
groupPermission('hudson.model.Item.Workspace', 'group2') | ||
} | ||
} | ||
|
||
// adds the build permission for the special anonymous user | ||
// adds the build permission to users | ||
job('example-2') { | ||
authorization { | ||
permission('hudson.model.Item.Build', 'anonymous') | ||
// requires matrix-auth > 3.0 | ||
permission('USER:hudson.model.Item.Workspace:user1') | ||
userPermission('hudson.model.Item.Workspace', 'user2') | ||
} | ||
} |
7 changes: 5 additions & 2 deletions
7
...n/docs/examples/javaposse/jobdsl/dsl/helpers/JobAuthorizationContext/permissionAll.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// add all permissions for user joe | ||
job('example') { | ||
// add all permissions | ||
job('example-1') { | ||
authorization { | ||
permissionAll('joe') | ||
// requires matrix-auth > 3.0 | ||
userPermissionAll('user1') | ||
groupPermissionAll('group1') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.