Skip to content

Commit 5204f7e

Browse files
authored
Merge pull request #2 from aramase/aramase/f/kep_3331_review_comments_1
address API review comments for extra mappings
2 parents c0be3a2 + 6706e65 commit 5204f7e

File tree

1 file changed

+40
-40
lines changed
  • keps/sig-auth/3331-structured-config-for-oidc-authentication

1 file changed

+40
-40
lines changed

keps/sig-auth/3331-structured-config-for-oidc-authentication/README.md

+40-40
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
130130

131131
This enhancement proposal covers adding structured authentication configuration to the Kubernetes API server.
132132
Initially, only a `jwt` configuration will be supported, which will serve as the next iteration of the existing
133-
OIDC authenticator. OIDC authentication is important part of Kubernetes, yet it has limitations in its current state.
133+
OIDC authenticator. OIDC authentication is an important part of Kubernetes, yet it has limitations in its current state.
134134
Below we will discuss that limitation and propose solutions.
135135

136136
# Motivation
@@ -223,10 +223,8 @@ jwt:
223223
uid:
224224
claim: 'sub'
225225
extra:
226-
- key:
227-
constant: 'client_name' # TODO: decide if we really need this flexibility or can we just have constant keys
228-
value:
229-
claim: 'aud'
226+
- key: 'client_name'
227+
valueExpression: 'claims.some_claim'
230228
# TODO(enj): drop this and figure out to get from CEL
231229
# claimFilters:
232230
# - username
@@ -260,8 +258,6 @@ is `sub` required or is the requirement to just have some username field?
260258
Payloads with nested data are supported as well (it will be possible
261259
to use the `foo` value as a claim mapping):
262260

263-
TODO(aramase): validate if CEL can work with multiple level of nesting
264-
265261
```json
266262
{
267263
"custom": {
@@ -290,7 +286,7 @@ type AuthenticationConfiguration struct {
290286

291287
// jwt is a list of OIDC providers to authenticate Kubernetes users.
292288
// For an incoming token, each JWT authenticator will be attempted in
293-
// the order in which it is specifcied in this list. Note however that
289+
// the order in which it is specified in this list. Note however that
294290
// other authenticators may run before or after the JWT authenticators.
295291
// The specific position of JWT authenticators in relation to other
296292
// authenticators is neither defined nor stable across releases. Since
@@ -325,7 +321,7 @@ type JWTAuthenticator struct {
325321
// ClaimsFilter []string `json:"claimFilters,omitempty"`
326322

327323
// userInfoValidationRules are rules that are applied to final userInfo before completing authentication.
328-
// These allow invariants to be applied to incoming identites such as preventing the
324+
// These allow invariants to be applied to incoming identities such as preventing the
329325
// use of the system: prefix that is commonly used by Kubernetes components.
330326
// +optional
331327
UserInfoValidationRules []UserInfoValidationRule `json:"userInfoValidationRules,omitempty"`
@@ -343,7 +339,7 @@ type JWTAuthenticator struct {
343339
// Required to be unique.
344340
URL string `json:"url,omitempty"`
345341

346-
// If specified, overrides the URL used to fetch discovery information.
342+
// discoveryURL if specified, overrides the URL used to fetch discovery information.
347343
// Format must be https://url/path.
348344
// Example:
349345
// curl oidc.oidc-namespace (.discoveryURL field)
@@ -373,24 +369,24 @@ type JWTAuthenticator struct {
373369

374370
```go
375371
type ClaimValidationRule struct {
376-
// Claim is the name of a required claim.
372+
// claim is the name of a required claim.
377373
// Same as --oidc-required-claim flag.
378374
// Only string claims are supported.
379375
// Mutually exclusive with expression and message.
380376
// +optional
381377
Claim string `json:"claim"`
382-
// RequiredValue is the value of a required claim.
378+
// requiredValue is the value of a required claim.
383379
// Same as --oidc-required-claim flag.
384380
// Mutually exclusive with expression and message.
385381
// +optional
386382
RequiredValue string `json:"requiredValue"`
387383

388-
// Expression is a logical expression that is written in CEL https://github.com/google/cel-go.
384+
// expression is a logical expression that is written in CEL https://github.com/google/cel-go.
389385
// Must return true for the validation to pass.
390386
// Mutually exclusive with claim and requiredValue.
391387
// +optional
392388
Expression string `json:"expression"`
393-
// Message customizes the returned error message when expression returns false.
389+
// message customizes the returned error message when expression returns false.
394390
// Mutually exclusive with claim and requiredValue.
395391
// Note that messageExpression is explicitly not supported to avoid
396392
// misconfigured expressions from leaking JWT payload contents.
@@ -421,7 +417,7 @@ type JWTAuthenticator struct {
421417

422418
```go
423419
type ClaimMappings struct {
424-
// Username represents an option for the username attribute.
420+
// username represents an option for the username attribute.
425421
// Claim must be a singular string claim.
426422
// TODO: decide whether to support a distributed claim for username (what are we required to correlate between the data retrieved for distributed claims? sub? something else?). Limit distributed claim support to OIDC things with clientID validation?
427423
// Expression must produce a string value.
@@ -431,55 +427,59 @@ type JWTAuthenticator struct {
431427
// (3) if userName.expression is set instead, result of expression is used as-is without any implicit prefix
432428
// (1) and (2) ensure backward compatibility with the --oidc-username-claim and --oidc-username-prefix flags
433429
Username PrefixedClaimOrExpression `json:"username"`
434-
// Groups represents an option for the groups attribute.
430+
// groups represents an option for the groups attribute.
435431
// Claim must be a string or string array claim.
436432
// Expression must produce a string or string array value.
437433
// "", [], missing, and null values are treated as having no groups.
438434
// TODO: investigate if you could make a single expression to construct groups from multiple claims. If not, maybe []PrefixedClaimOrExpression?
439435
// +optional
440436
Groups PrefixedClaimOrExpression `json:"groups,omitempty"`
441-
// UID represents an option for the uid attribute.
437+
// uid represents an option for the uid attribute.
442438
// Claim must be a singular string claim.
443439
// Expression must produce a string value.
444440
// TODO: this is net new, should it just be expression?
445441
// +optional
446442
UID ClaimOrExpression `json:"uid,omitempty"`
447-
// Extra represents an option for the extra attribute.
443+
// extra represents an option for the extra attribute.
444+
//
445+
// # hard-coded extra key/value
446+
// - key: "foo"
447+
// valueExpression: "bar"
448448
//
449-
// TODO: examples for this?
449+
// hard-coded key, value copying claim value
450+
// - key: "foo"
451+
// valueExpression: "claims.some_claim"
450452
//
451-
// # known key, value from claim
452-
// - key: "example.com/myextrakey"
453-
// value:
454-
// claim: "hd"
453+
// hard-coded key, value derived from claim value
454+
// - key: "admin"
455+
// valueExpression: '(has(claims.is_admin) && claims.is_admin) ? "true":""'
455456
//
456-
// # known key, value constructed by expression
457-
// - key: "example.com/myextrakey"
458-
// value:
459-
// expression: claims.someclaim+":"+claims.someclaim
457+
// If multiple mappings have the same key, the result will be a concatenation of all values
458+
// with the order preserved.
459+
// If the value is empty, the extra mapping will not be present.
460460
//
461-
// # calculated key/value pairs? CEL returns [{key,value}, {key,[value, value...]}, ...] and we aggregate?
462-
// TODO: ask joe/cici about CEL constructing/returning complex types
461+
// possible future way to pull multiple extra values out via expression.
462+
// TODO: confirm cel comprehensions/mapping is powerful enough to transform
463+
// the input claims into a filtered / transformed map[string][]string output):
464+
// # mutually exclusive with key/valueExpression
465+
// keyAndValueExpression: '{"key":"string-value", "key2": ["value1","value2"]}'
463466
//
464467
// +optional
465468
Extra []ExtraMapping `json:"extra,omitempty"`
466469
}
467470
468471
type ExtraMapping struct {
469-
// Key is a CEL expression to extract extra attribute key.
470-
// Claim must be a singular string claim.
471-
// Expression must produce a string value.
472-
// "" and null values are treated as the extra mapping not being present.
472+
// key is a string to use as the extra attribute key.
473473
Key string `json:"key"`
474-
// Value is a CEL expression to extract extra attribute value.
475-
// Claim must be a string or string array claim.
476-
// Expression must produce a string or string array value.
474+
// valueExpression is a CEL expression to extract extra attribute value.
475+
// valueExpression must produce a string or string array value.
477476
// "", [], and null values are treated as the extra mapping not being present.
478-
Value ClaimOrExpression `json:"value"`
477+
// Empty string values contained within a string array are filtered out.
478+
ValueExpression string `json:"valueExpression"`
479479
}
480480
481481
type ClaimOrExpression struct {
482-
// Claim is the JWT claim to use.
482+
// claim is the JWT claim to use.
483483
// Either claim or expression must be set.
484484
// +optional
485485
Claim string `json:"claim"`
@@ -490,11 +490,11 @@ type JWTAuthenticator struct {
490490
491491
492492
type PrefixedClaimOrExpression struct {
493-
// Claim is the JWT claim to use.
493+
// claim is the JWT claim to use.
494494
// Either claim or expression must be set.
495495
// +optional
496496
Claim string `json:"claim"`
497-
// Prefix is prepended to claim to prevent clashes with existing names.
497+
// prefix is prepended to claim to prevent clashes with existing names.
498498
// Mutually exclusive with expression.
499499
// +optional
500500
Prefix string `json:"prefix"`

0 commit comments

Comments
 (0)