-
Notifications
You must be signed in to change notification settings - Fork 573
CNTRLPLANE-311: adding auth config missing fields to API #2487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ShazaAldawamneh
wants to merge
5
commits into
openshift:master
Choose a base branch
from
ShazaAldawamneh:CNTRLPLANE-311-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
364 changes: 364 additions & 0 deletions
364
config/v1/tests/authentications.config.openshift.io/ExternalOIDCWithNewAuthConfigFields.yaml
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,364 @@ | ||
|
||
apiVersion: apiextensions.k8s.io/v1 | ||
name: "Authentication" | ||
crdName: authentications.config.openshift.io | ||
featureGates: | ||
- ExternalOIDCWithNewAuthConfigFields | ||
tests: | ||
onCreate: | ||
- name: Valid discoveryURL | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: https://auth.example.com/.well-known/openid-configuration | ||
|
||
- name: discoveryURL must be a valid URL | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: not-a-valid-url | ||
error: "discoveryURL must be a valid URL" | ||
ShazaAldawamneh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- name: discoveryURL must not contain user info | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: https://user:[email protected]/ | ||
error: "discoveryURL must not contain user info" | ||
|
||
- name: discoveryURL exceeds max length | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: "https://auth.example.com/$(printf 'a%.0s' {1..2050})" | ||
error: "discoveryURL: Too long" | ||
|
||
- name: discoveryURL must not contain fragment | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: https://auth.example.com/#fragment | ||
error: "discoveryURL must not contain a fragment" | ||
|
||
- name: discoveryURL must use https | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: http://auth.example.com/invalid | ||
error: "discoveryURL must use https scheme" | ||
|
||
- name: discoveryURL must not contain query | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: https://auth.example.com/path?foo=bar | ||
error: "discoveryURL must not contain query parameters" | ||
|
||
- name: discoveryURL must be different from URL | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld/ | ||
audiences: ['openshift-aud'] | ||
discoveryURL: https://auth.example.com/ | ||
error: "discoveryURL must be different from URL" | ||
|
||
- name: Valid AudienceMatchPolicy | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
audienceMatchPolicy: MatchAny | ||
|
||
- name: Invalid AudienceMatchPolicy | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
audienceMatchPolicy: InvalidPolicy | ||
error: "audienceMatchPolicy: Unsupported value" | ||
|
||
- name: Valid RequiredClaim rule | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: RequiredClaim | ||
requiredClaim: | ||
claim: "role" | ||
requiredValue: "admin" | ||
|
||
- name: Missing requiredClaim when type is RequiredClaim | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: RequiredClaim | ||
expectedError: "requiredClaim must be set when type is 'RequiredClaim'" | ||
|
||
- name: Valid ExpressionRule configuration | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: Expression | ||
expressionRule: | ||
expression: "claims.email.endsWith('@example.com')" | ||
message: "email must be from example.com" | ||
expected: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: Expression | ||
expressionRule: | ||
expression: "claims.email.endsWith('@example.com')" | ||
message: "email must be from example.com" | ||
|
||
- name: Missing expressionRule for Expression type | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: Expression | ||
expectedError: "expressionRule must be set when type is 'Expression', and forbidden otherwise" | ||
|
||
- name: Expression too long | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: Expression | ||
expressionRule: | ||
expression: "{{longExpression}}" | ||
replacements: | ||
longExpression: "{{'x' * 5000}}" | ||
expectedError: "expression: Too long: must have at most 4096 characters" | ||
|
||
- name: Empty expression in expressionRule | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
claimValidationRules: | ||
- type: Expression | ||
expressionRule: | ||
expression: "" | ||
message: "must not be empty" | ||
expectedError: "expression: Invalid value: \"\": validation failed: value length must be at least 1" | ||
|
||
- name: Valid TokenUserValidationRule with expression and message | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- expression: "user.username.startsWith('admin')" | ||
message: "Only admin users are allowed" | ||
expected: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- expression: "user.username.startsWith('admin')" | ||
message: "Only admin users are allowed" | ||
|
||
- name: Missing expression in TokenUserValidationRule | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- message: "Should never reach here" | ||
expectedError: "expression: Required value" | ||
|
||
- name: Expression too long in TokenUserValidationRule | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- expression: "{{longExpression}}" | ||
message: "This expression is too long" | ||
replacements: | ||
longExpression: "{{'x' * 5000}}" | ||
expectedError: "expression: Too long: must have at most 4096 characters" | ||
|
||
- name: Empty expression in TokenUserValidationRule | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- expression: "" | ||
message: "Empty expressions are invalid" | ||
expectedError: "expression: Invalid value: \"\": validation failed: value length must be at least 1" | ||
|
||
- name: Valid TokenUserValidationRule with expression only | ||
initial: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- expression: "user.groups.exists(g, g == 'admins')" | ||
expected: | | ||
apiVersion: config.openshift.io/v1 | ||
kind: Authentication | ||
spec: | ||
type: OIDC | ||
oidcProviders: | ||
- name: myoidc | ||
issuer: | ||
issuerURL: https://meh.tld | ||
audiences: ['openshift-aud'] | ||
userValidationRules: | ||
- expression: "user.groups.exists(g, g == 'admins')" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.