CNTRLPLANE-3010: Add API-side validation to enforce prefixPolicy is not set when username expression is used#2771
Conversation
…when username expression is used Signed-off-by: Shaza Aldawamneh <shaza.aldawamneh@hotmail.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@ShazaAldawamneh: This pull request references CNTRLPLANE-3010 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
Hello @ShazaAldawamneh! Some important instructions when contributing to openshift/api: |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…when username expression is used Signed-off-by: Shaza Aldawamneh <shaza.aldawamneh@hotmail.com>
|
@ShazaAldawamneh: This pull request references CNTRLPLANE-3010 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@ShazaAldawamneh: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
| // +openshift:validation:FeatureGateAwareXValidation:featureGate=ExternalOIDC,rule="has(self.claim)",message="claim is required" | ||
| // +openshift:validation:FeatureGateAwareXValidation:featureGate=ExternalOIDCWithUIDAndExtraClaimMappings,rule="has(self.claim)",message="claim is required" | ||
| // +openshift:validation:FeatureGateAwareXValidation:featureGate=ExternalOIDCWithUpstreamParity,rule="has(self.claim) ? !has(self.expression) : has(self.expression)",message="precisely one of claim or expression must be set" | ||
| // +openshift:validation:FeatureGateAwareXValidation:featureGate=ExternalOIDCWithUpstreamParity,rule="has(self.expression) && size(self.expression) > 0 ? !has(self.prefixPolicy) || self.prefixPolicy != 'Prefix' : true",message="prefixPolicy must not be set to 'Prefix' when expression is set" |
There was a problem hiding this comment.
We want this for groups also right?
Add a FeatureGateAwareXValidation rule to the UsernameClaimMapping type in the authentications.config.openshift.io CRD to reject configurations where prefixPolicy is set to Prefix when a username expression is also set.
Previously, this validation was only enforced at runtime in the CAO and HyperShift generation code. This change moves the validation to the API admission layer, providing stronger validation at resource creation/update time before the resource is persisted.
A prefixPolicy of Prefix is not applicable when using an expression-based username mapping since prefixes should be set directly within the expression itself if needed.
New test cases are added to the ExternalOIDCWithUpstreamParity CRD validation tests to cover: