-
Notifications
You must be signed in to change notification settings - Fork 874
OCPBUGS-56908: validate identity provider names as annotation keys #3025
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 |
|---|---|---|
|
|
@@ -38,6 +38,13 @@ type OAuth struct { | |
| type OAuthSpec struct { | ||
| // identityProviders is an ordered list of ways for a user to identify themselves. | ||
| // When this list is empty, no identities are provisioned for users. | ||
| // | ||
| // name is also used as the name-part of the Group annotation | ||
| // oauth.openshift.io/idp.<name> during OpenID group sync, so it must be a valid | ||
| // Kubernetes annotation name (alphanumeric, '-', '_', '.', at most 59 characters). | ||
| // Existing names that predate this restriction are grandfathered until changed. | ||
| // | ||
| // +kubebuilder:validation:XValidation:rule="self.all(idp, (idp.name.matches('^[A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])?$') && size(idp.name) <= 59) || (oldSelf.hasValue() && oldSelf.value().exists(old, old.name == idp.name)))",message="identity provider name must consist of alphanumeric characters, '-', '_' or '.', start and end with an alphanumeric character, and be at most 59 characters because it is used as a Kubernetes annotation key during group sync",optionalOldSelf=true | ||
|
Comment on lines
+42
to
+47
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. Instead of this being a validation on this field, we can probably just add equivalent validation on the actual |
||
| // +optional | ||
| // +listType=atomic | ||
| IdentityProviders []IdentityProvider `json:"identityProviders,omitempty"` | ||
|
|
@@ -139,6 +146,9 @@ type IdentityProvider struct { | |
| // - It MUST be unique and not shared by any other identity provider used | ||
| // - It MUST be a valid path segment: name cannot equal "." or ".." or contain "/" or "%" or ":" | ||
| // Ref: https://godoc.org/github.com/openshift/origin/pkg/user/apis/user/validation#ValidateIdentityProviderName | ||
| // - It MUST also be a valid Kubernetes annotation name-part (alphanumeric characters, | ||
| // '-', '_' or '.', starting and ending with an alphanumeric character, at most 59 characters) | ||
| // because oauth-server writes oauth.openshift.io/idp.<name> onto Group objects during group sync. | ||
| Name string `json:"name"` | ||
|
|
||
| // mappingMethod determines how identities from this provider are mapped to users | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
We also want to test that the change to the validation successfully ratchets. The tests in
api/example/v1/tests/stableconfigtypes.example.openshift.io/AAA_ungated.yaml
Lines 902 to 964 in 8127870