Skip to content

Commit efcb568

Browse files
authored
Merge pull request #78 from embik/oidc-serviceaccount-validation
Add validation to FrontProxy to ensure that OIDC requires ServiceAccount auth
2 parents 45f2b93 + 3ef93e1 commit efcb568

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

config/crd/bases/operator.kcp.io_frontproxies.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ spec:
7777
type: object
7878
type: array
7979
auth:
80-
description: 'Optional: Auth configures various aspects of Authentication
81-
and Authorization for this front-proxy instance.'
80+
description: |-
81+
Optional: Auth configures various aspects of Authentication and Authorization for this front-proxy instance.
82+
If OIDC is enabled, it also requires enabling ServiceAccount authentication (as front-proxy will start validating JWT tokens, which includes ServiceAccount tokens).
8283
properties:
8384
dropGroups:
8485
description: 'Optional: DropGroups configures groups to be dropped
@@ -144,6 +145,9 @@ spec:
144145
- enabled
145146
type: object
146147
type: object
148+
x-kubernetes-validations:
149+
- message: OIDC requires ServiceAccount auth to be enabled.
150+
rule: '!has(self.oidc) || (has(self.serviceAccount) && self.serviceAccount.enabled)'
147151
certificateTemplates:
148152
additionalProperties:
149153
properties:

config/samples/operator.kcp.io_v1alpha1_frontproxy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ metadata:
66
app.kubernetes.io/managed-by: kustomize
77
name: frontproxy-sample
88
spec:
9+
auth:
10+
serviceAccount:
11+
enabled: true
912
rootShard:
1013
ref:
1114
name: shard-sample

config/samples/v1alpha1_kubeconfig_admin.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

sdk/apis/operator/v1alpha1/frontproxy_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type FrontProxySpec struct {
3030
// Resources overrides the default resource requests and limits.
3131
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
3232
// Optional: Auth configures various aspects of Authentication and Authorization for this front-proxy instance.
33+
// If OIDC is enabled, it also requires enabling ServiceAccount authentication (as front-proxy will start validating JWT tokens, which includes ServiceAccount tokens).
34+
// +kubebuilder:validation:XValidation:rule="!has(self.oidc) || (has(self.serviceAccount) && self.serviceAccount.enabled)",message="OIDC requires ServiceAccount auth to be enabled."
3335
Auth *AuthSpec `json:"auth,omitempty"`
3436
// Optional: AdditionalPathMappings configures // TODO ?
3537
AdditionalPathMappings []PathMappingEntry `json:"additionalPathMappings,omitempty"`

0 commit comments

Comments
 (0)