Skip to content
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

AUTH-439: authentication: use CRD validation for the 'type' field #1716

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ spec:
type:
description: type identifies the cluster managed, user facing authentication mode in use. Specifically, it manages the component that responds to login attempts. The default is IntegratedOAuth.
type: string
enum:
- ""
- None
- IntegratedOAuth
- OIDC
webhookTokenAuthenticator:
description: "webhookTokenAuthenticator configures a remote token reviewer. These remote authentication webhooks can be used to verify bearer tokens via the tokenreviews.authentication.k8s.io REST API. This is required to honor bearer tokens that are provisioned by an external authentication service. \n Can only be set if \"Type\" is set to \"None\"."
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ spec:
type:
description: type identifies the cluster managed, user facing authentication mode in use. Specifically, it manages the component that responds to login attempts. The default is IntegratedOAuth.
type: string
enum:
- ""
- None
- IntegratedOAuth
- OIDC
webhookTokenAuthenticator:
description: "webhookTokenAuthenticator configures a remote token reviewer. These remote authentication webhooks can be used to verify bearer tokens via the tokenreviews.authentication.k8s.io REST API. This is required to honor bearer tokens that are provisioned by an external authentication service. \n Can only be set if \"Type\" is set to \"None\"."
type: object
Expand Down
4 changes: 4 additions & 0 deletions config/v1/0000_10_config-operator_01_authentication.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ spec:
type:
description: type identifies the cluster managed, user facing authentication mode in use. Specifically, it manages the component that responds to login attempts. The default is IntegratedOAuth.
type: string
enum:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened in 4.14 if this string value had a different value for this field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had a separate validation in our o/k fork that did not allow this - openshift/kubernetes#1770

- ""
- None
- IntegratedOAuth
webhookTokenAuthenticator:
description: "webhookTokenAuthenticator configures a remote token reviewer. These remote authentication webhooks can be used to verify bearer tokens via the tokenreviews.authentication.k8s.io REST API. This is required to honor bearer tokens that are provisioned by an external authentication service. \n Can only be set if \"Type\" is set to \"None\"."
type: object
Expand Down
11 changes: 11 additions & 0 deletions config/v1/custom.authentication.testsuite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ tests:
apiVersion: config.openshift.io/v1
kind: Authentication
spec: {}
- name: Should be able to use the OIDC type
initial: |
apiVersion: config.openshift.io/v1
kind: Authentication
spec:
type: OIDC
expected: |
apiVersion: config.openshift.io/v1
kind: Authentication
spec:
type: OIDC
- name: Cannot set username claim prefix with policy NoPrefix
initial: |
apiVersion: config.openshift.io/v1
Expand Down
7 changes: 7 additions & 0 deletions config/v1/stable.authentication.testsuite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ tests:
apiVersion: config.openshift.io/v1
kind: Authentication
spec: {}
- name: Shouldn't be able to use the OIDC type in a stable version of the resource
initial: |
apiVersion: config.openshift.io/v1
kind: Authentication
spec:
type: OIDC
expectedError: "spec.type: Unsupported value: \"OIDC\": supported values: \"\", \"None\", \"IntegratedOAuth\""
13 changes: 12 additions & 1 deletion config/v1/techpreview.authentication.testsuite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ tests:
apiVersion: config.openshift.io/v1
kind: Authentication
spec: {}
- name: Should be able to use the OIDC type
initial: |
apiVersion: config.openshift.io/v1
kind: Authentication
spec:
type: OIDC
expected: |
apiVersion: config.openshift.io/v1
kind: Authentication
spec:
type: OIDC
- name: Cannot set username claim prefix with policy NoPrefix
initial: |
apiVersion: config.openshift.io/v1
Expand Down Expand Up @@ -284,4 +295,4 @@ tests:
componentName: name2
- componentNamespace: namespace2
componentName: name3
expected: *removeFromStatus
expected: *removeFromStatus
2 changes: 2 additions & 0 deletions config/v1/types_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ type AuthenticationList struct {
Items []Authentication `json:"items"`
}

// +openshift:validation:FeatureSetAwareEnum:featureSet=Default,enum="";None;IntegratedOAuth
// +openshift:validation:FeatureSetAwareEnum:featureSet=CustomNoUpgrade;TechPreviewNoUpgrade,enum="";None;IntegratedOAuth;OIDC
type AuthenticationType string

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ spec:
type:
description: type identifies the cluster managed, user facing authentication mode in use. Specifically, it manages the component that responds to login attempts. The default is IntegratedOAuth.
type: string
enum:
- ""
- None
- IntegratedOAuth
- OIDC
webhookTokenAuthenticator:
description: "webhookTokenAuthenticator configures a remote token reviewer. These remote authentication webhooks can be used to verify bearer tokens via the tokenreviews.authentication.k8s.io REST API. This is required to honor bearer tokens that are provisioned by an external authentication service. \n Can only be set if \"Type\" is set to \"None\"."
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ spec:
type:
description: type identifies the cluster managed, user facing authentication mode in use. Specifically, it manages the component that responds to login attempts. The default is IntegratedOAuth.
type: string
enum:
- ""
- None
- IntegratedOAuth
- OIDC
webhookTokenAuthenticator:
description: "webhookTokenAuthenticator configures a remote token reviewer. These remote authentication webhooks can be used to verify bearer tokens via the tokenreviews.authentication.k8s.io REST API. This is required to honor bearer tokens that are provisioned by an external authentication service. \n Can only be set if \"Type\" is set to \"None\"."
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ spec:
type:
description: type identifies the cluster managed, user facing authentication mode in use. Specifically, it manages the component that responds to login attempts. The default is IntegratedOAuth.
type: string
enum:
- ""
- None
- IntegratedOAuth
webhookTokenAuthenticator:
description: "webhookTokenAuthenticator configures a remote token reviewer. These remote authentication webhooks can be used to verify bearer tokens via the tokenreviews.authentication.k8s.io REST API. This is required to honor bearer tokens that are provisioned by an external authentication service. \n Can only be set if \"Type\" is set to \"None\"."
type: object
Expand Down