Skip to content

Commit b209a62

Browse files
carloryrichabanker
authored andcommitted
Fix OIDC flags
1 parent 847be85 commit b209a62

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/kubeapiserver/options/authentication.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ func (o *BuiltInAuthenticationOptions) WithClientCert() *BuiltInAuthenticationOp
203203

204204
// WithOIDC set default value for OIDC authentication
205205
func (o *BuiltInAuthenticationOptions) WithOIDC() *BuiltInAuthenticationOptions {
206-
o.OIDC = &OIDCAuthenticationOptions{areFlagsConfigured: func() bool { return false }}
206+
o.OIDC = &OIDCAuthenticationOptions{
207+
areFlagsConfigured: func() bool { return false },
208+
UsernameClaim: "sub",
209+
SigningAlgs: []string{"RS256"},
210+
}
207211
return o
208212
}
209213

@@ -353,33 +357,33 @@ func (o *BuiltInAuthenticationOptions) AddFlags(fs *pflag.FlagSet) {
353357
"The URL of the OpenID issuer, only HTTPS scheme will be accepted. "+
354358
"If set, it will be used to verify the OIDC JSON Web Token (JWT).")
355359

356-
fs.StringVar(&o.OIDC.ClientID, oidcClientIDFlag, o.OIDC.ClientID,
360+
fs.StringVar(&o.OIDC.ClientID, oidcClientIDFlag, o.OIDC.ClientID, ""+
357361
"The client ID for the OpenID Connect client, must be set if oidc-issuer-url is set.")
358362

359363
fs.StringVar(&o.OIDC.CAFile, oidcCAFileFlag, o.OIDC.CAFile, ""+
360364
"If set, the OpenID server's certificate will be verified by one of the authorities "+
361365
"in the oidc-ca-file, otherwise the host's root CA set will be used.")
362366

363-
fs.StringVar(&o.OIDC.UsernameClaim, oidcUsernameClaimFlag, "sub", ""+
367+
fs.StringVar(&o.OIDC.UsernameClaim, oidcUsernameClaimFlag, o.OIDC.UsernameClaim, ""+
364368
"The OpenID claim to use as the user name. Note that claims other than the default ('sub') "+
365369
"is not guaranteed to be unique and immutable. This flag is experimental, please see "+
366370
"the authentication documentation for further details.")
367371

368-
fs.StringVar(&o.OIDC.UsernamePrefix, oidcUsernamePrefixFlag, "", ""+
372+
fs.StringVar(&o.OIDC.UsernamePrefix, oidcUsernamePrefixFlag, o.OIDC.UsernamePrefix, ""+
369373
"If provided, all usernames will be prefixed with this value. If not provided, "+
370374
"username claims other than 'email' are prefixed by the issuer URL to avoid "+
371375
"clashes. To skip any prefixing, provide the value '-'.")
372376

373-
fs.StringVar(&o.OIDC.GroupsClaim, oidcGroupsClaimFlag, "", ""+
377+
fs.StringVar(&o.OIDC.GroupsClaim, oidcGroupsClaimFlag, o.OIDC.GroupsClaim, ""+
374378
"If provided, the name of a custom OpenID Connect claim for specifying user groups. "+
375379
"The claim value is expected to be a string or array of strings. This flag is experimental, "+
376380
"please see the authentication documentation for further details.")
377381

378-
fs.StringVar(&o.OIDC.GroupsPrefix, oidcGroupsPrefixFlag, "", ""+
382+
fs.StringVar(&o.OIDC.GroupsPrefix, oidcGroupsPrefixFlag, o.OIDC.GroupsPrefix, ""+
379383
"If provided, all groups will be prefixed with this value to prevent conflicts with "+
380384
"other authentication strategies.")
381385

382-
fs.StringSliceVar(&o.OIDC.SigningAlgs, oidcSigningAlgsFlag, []string{"RS256"}, ""+
386+
fs.StringSliceVar(&o.OIDC.SigningAlgs, oidcSigningAlgsFlag, o.OIDC.SigningAlgs, ""+
383387
"Comma-separated list of allowed JOSE asymmetric signing algorithms. JWTs with a "+
384388
"supported 'alg' header values are: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512. "+
385389
"Values are defined by RFC 7518 https://tools.ietf.org/html/rfc7518#section-3.1.")

0 commit comments

Comments
 (0)