Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added =
Empty file.
69 changes: 43 additions & 26 deletions demos/global-matrix-auth/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# matrix-auth-plugin

Requires `matrix-auth` >= 3.0
Requires `matrix-auth` >= 3.2

There are a couple of built-in authorizations to consider.

Expand All @@ -13,39 +13,56 @@ There are a couple of built-in authorizations to consider.
jenkins:
authorizationStrategy:
globalMatrix:
permissions:
- "USER:Overall/Read:anonymous"
- "GROUP:Overall/Administer:authenticated"
- "USER:Overall/Administer:admin"
entries:
- user:
name: "admin"
permissions:
- "Overall/Administer"
- user:
name: "anonymous"
permissions:
- "Overall/Read"
- group:
name: "authenticated"
permissions:
- "Overall/Read"
- "Job/Build"
- "Job/Create"
```
Permissions must be defined **per line**, meaning each line must grant permission to only a single role, and only a single user or group of users.


## sample-configuration (project based matrix)

```yaml
jenkins:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the integration test to use this to prove it works please (and continues to work):

https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/integrations/src/test/java/io/jenkins/plugins/casc/ProjectMatrixAuthorizationTest.java

It will need to change to use the JenkinsConfiguredWithReadmeRule

You can then append #<heading-number> to the ConfiguredWithReadme so that it uses the right example, like in:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a pleasure for me to work on the repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you haven't done this

authorizationStrategy:
projectMatrix:
permissions:
- "View/Delete:authenticated"
- "View/Read:authenticated"
- "View/Configure:authenticated"
- "View/Create:authenticated"
- "Job/Read:authenticated"
- "Job/Build:authenticated"
- "Job/Configure:authenticated"
- "Job/Create:authenticated"
- "Job/Delete:authenticated"
- "Job/Discover:authenticated"
- "Job/Move:authenticated"
- "Job/Workspace:authenticated"
- "Job/Cancel:authenticated"
- "Run/Delete:authenticated"
- "Run/Replay:authenticated"
- "Run/Update:authenticated"
- "SCM/Tag:authenticated"
- "Overall/Read:anonymous"
- "Overall/Administer:authenticated"
entries:
- group:
name: "authenticated"
permissions:
- "View/Delete"
- "View/Read"
- "View/Configure"
- "View/Create"
- "Job/Read"
- "Job/Build"
- "Job/Configure"
- "Job/Create"
- "Job/Delete"
- "Job/Discover"
- "Job/Move"
- "Job/Workspace"
- "Job/Cancel"
- "Run/Delete"
- "Run/Replay"
- "Run/Update"
- "SCM/Tag"
- "Overall/Administer"
- user:
name: "anonymous"
permissions:
- "Overall/Read"
```

Some permissions depends on actual plugin-usage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import hudson.security.ProjectMatrixAuthorizationStrategy;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import io.jenkins.plugins.casc.misc.ConfiguredWithReadme;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithReadmeRule;
import io.jenkins.plugins.casc.misc.junit.jupiter.WithJenkinsConfiguredWithCode;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -18,8 +18,8 @@
class ProjectMatrixAuthorizationTest {

@Test
@ConfiguredWithCode("ProjectMatrixStrategy.yml")
void checkCorrectlyConfiguredPermissions(JenkinsConfiguredWithCodeRule j) {
@ConfiguredWithReadme("global-matrix-auth/README.md#2")
void checkCorrectlyConfiguredPermissions(JenkinsConfiguredWithReadmeRule j) {
assertEquals(
ProjectMatrixAuthorizationStrategy.class,
Jenkins.get().getAuthorizationStrategy().getClass(),
Expand Down