Skip to content

Commit 916c786

Browse files
committed
fix godoc for email_verified requirement when username contains claims.email
Using 'claims.?email_verified.orValue(true) == true' in the example validation rule. By explicitly comparing the value to true, we let type-checking see the result will be a boolean, and to make sure a non-boolean email_verified claim will be caught at runtime. Signed-off-by: Anish Ramasekar <[email protected]>
1 parent 917a556 commit 916c786

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1alpha1/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ type ClaimMappings struct {
352352
// If username.expression uses 'claims.email', then 'claims.email_verified' must be used in
353353
// username.expression or extra[*].valueExpression or claimValidationRules[*].expression.
354354
// An example claim validation rule expression that matches the validation automatically
355-
// applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true)'.
355+
// applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true) == true'. By explicitly comparing
356+
// the value to true, we let type-checking see the result will be a boolean, and to make sure a non-boolean email_verified
357+
// claim will be caught at runtime.
356358
//
357359
// In the flag based approach, the --oidc-username-claim and --oidc-username-prefix are optional. If --oidc-username-claim is not set,
358360
// the default value is "sub". For the authentication config, there is no defaulting for claim or prefix. The claim and prefix must be set explicitly.

staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1beta1/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ type ClaimMappings struct {
323323
// If username.expression uses 'claims.email', then 'claims.email_verified' must be used in
324324
// username.expression or extra[*].valueExpression or claimValidationRules[*].expression.
325325
// An example claim validation rule expression that matches the validation automatically
326-
// applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true)'.
326+
// applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true) == true'. By explicitly comparing
327+
// the value to true, we let type-checking see the result will be a boolean, and to make sure a non-boolean email_verified
328+
// claim will be caught at runtime.
327329
//
328330
// In the flag based approach, the --oidc-username-claim and --oidc-username-prefix are optional. If --oidc-username-claim is not set,
329331
// the default value is "sub". For the authentication config, there is no defaulting for claim or prefix. The claim and prefix must be set explicitly.

0 commit comments

Comments
 (0)