-
Notifications
You must be signed in to change notification settings - Fork 591
[WIP]: CNTRLPLANE-2550: Add support for CEL expression claim mappings for username and groups #2719
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,15 +591,35 @@ type OIDCClientReference struct { | |
| // +kubebuilder:validation:XValidation:rule="has(self.prefixPolicy) && self.prefixPolicy == 'Prefix' ? (has(self.prefix) && size(self.prefix.prefixString) > 0) : !has(self.prefix)",message="prefix must be set if prefixPolicy is 'Prefix', but must remain unset otherwise" | ||
| // +union | ||
| type UsernameClaimMapping struct { | ||
| // claim is a required field that configures the JWT token claim whose value is assigned to the cluster identity field associated with this mapping. | ||
| // claim is a optional field that configures the JWT token claim whose value is assigned to the cluster identity field associated with this mapping. | ||
| // | ||
| // Precisely one of claim or expression must be set if the | ||
| // ExternalOIDCWithUpstreamParity feature gate is enabled. | ||
| // | ||
| // claim must not be an empty string ("") and must not exceed 256 characters. | ||
| // | ||
| // +required | ||
| // +optional | ||
| // +kubebuilder:validation:MinLength:=1 | ||
| // +kubebuilder:validation:MaxLength:=256 | ||
| Claim string `json:"claim"` | ||
|
|
||
| // expression is an optional CEL expression used to derive | ||
| // the username from JWT claims. | ||
| // | ||
| // CEL expressions have access to the token claims | ||
| // through a CEL variable, 'claims'. | ||
| // | ||
| // Precisely one of claim or expression must be set if the | ||
| // ExternalOIDCWithUpstreamParity feature gate is enabled. | ||
| // | ||
| // +optional | ||
| // +openshift:enable:FeatureGate=ExternalOIDCWithUpstreamParity | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=1024 | ||
| // +kubebuilder:validation:XValidation:rule="has(self.expression) ? !has(self.claim) : true",message="claim must not be set when expression is provided" | ||
|
|
||
| Expression string `json:"expression,omitempty"` | ||
|
|
||
| // prefixPolicy is an optional field that configures how a prefix should be applied to the value of the JWT claim specified in the 'claim' field. | ||
| // | ||
| // Allowed values are 'Prefix', 'NoPrefix', and omitted (not provided or an empty string). | ||
|
|
@@ -668,6 +688,18 @@ type UsernamePrefix struct { | |
| type PrefixedClaimMapping struct { | ||
| TokenClaimMapping `json:",inline"` | ||
|
|
||
| // expression is an optional CEL expression used to derive | ||
| // group values from JWT claims. | ||
| // | ||
| // When specified, claim must not be set. | ||
| // | ||
| // +optional | ||
| // +openshift:enable:FeatureGate=ExternalOIDCWithUpstreamParity | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=1024 | ||
| // +kubebuilder:validation:XValidation:rule="has(self.expression) ? !has(self.claim) : true",message="claim must not be set when expression is provided" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be moved to the struct level and needs to be feature gated. |
||
| Expression string `json:"expression,omitempty"` | ||
|
Comment on lines
+691
to
+701
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this instead be added to the |
||
|
|
||
| // prefix is an optional field that configures the prefix that will be applied to the cluster identity attribute during the process of mapping JWT claims to cluster identity attributes. | ||
| // | ||
| // When omitted (""), no prefix is applied to the cluster identity attribute. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be moved to the struct level and needs to be feature gated