-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add way to forbid an oidc authorization access item in list
- Loading branch information
1 parent
8ad1850
commit 099c26a
Showing
5 changed files
with
89 additions
and
12 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
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 |
---|---|---|
|
@@ -156,3 +156,42 @@ Accesses will be: | |
- Jean Dupont: authorized | ||
- Astérix: authorized | ||
- Obélix: forbidden | ||
|
||
### Forbidden case | ||
|
||
<!-- prettier-ignore-start --> | ||
!!! note | ||
|
||
This have been done because there isn't any way of doing a negative match on regex. The only way is to match a regex with a forbidden flag enabled. | ||
<!-- prettier-ignore-end --> | ||
|
||
Example of authorization accesses configuration: | ||
|
||
```yaml | ||
targets: | ||
target1: | ||
resources: | ||
- path: /* | ||
provider: provider1 | ||
oidc: | ||
authorizationAccesses: | ||
- email: [email protected] | ||
regex: true | ||
forbidden: true | ||
- email: .*@fake.com | ||
regex: true | ||
bucket: | ||
... | ||
``` | ||
|
||
We consider those users: | ||
|
||
- Jean Dupont with `[email protected]` email | ||
- Astérix with `[email protected]` email | ||
- Obélix with `[email protected]` email | ||
|
||
Accesses will be: | ||
|
||
- Jean Dupont: authorized | ||
- Astérix: forbidden because it is marked as forbidden and it is the first in the list | ||
- Obélix: forbidden |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,42 @@ func Test_isHeaderOIDCAuthorizedBasic(t *testing.T) { | |
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "should be forbidden if email regexp is matching but forbidden", | ||
args: args{ | ||
groups: make([]string, 0), | ||
email: "[email protected]", | ||
authorizationAccesses: []*config.HeaderOIDCAuthorizationAccess{ | ||
{ | ||
Regexp: true, | ||
Email: ".*@valid.test", | ||
EmailRegexp: regexp.MustCompile(".*@valid.test"), | ||
Forbidden: true, | ||
}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "should be forbidden if email regexp is matching but forbidden but second have ok for groups", | ||
args: args{ | ||
groups: []string{"grp1"}, | ||
email: "[email protected]", | ||
authorizationAccesses: []*config.HeaderOIDCAuthorizationAccess{ | ||
{ | ||
Regexp: true, | ||
Email: ".*@valid.test", | ||
EmailRegexp: regexp.MustCompile(".*@valid.test"), | ||
Forbidden: true, | ||
}, | ||
{ | ||
Regexp: true, | ||
Group: "grp1", | ||
}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
|
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