Skip to content

Commit 2ae3be9

Browse files
committed
update extra mapping
Signed-off-by: Anish Ramasekar <[email protected]>
1 parent c0be3a2 commit 2ae3be9

File tree

1 file changed

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

1 file changed

+26
-28
lines changed

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

Lines changed: 26 additions & 28 deletions
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"`
@@ -446,36 +442,38 @@ type JWTAuthenticator struct {
446442
UID ClaimOrExpression `json:"uid,omitempty"`
447443
// Extra represents an option for the extra attribute.
448444
//
449-
// TODO: examples for this?
445+
// # hard-coded extra key/value
446+
// - key: "foo"
447+
// valueExpression: "bar"
448+
//
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+
// If the value is empty, the extra mapping will not be present.
460459
//
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
460+
// possible future way to pull multiple extra values out via expression.
461+
// TODO: confirm cel comprehensions/mapping is powerful enough to transform
462+
// the input claims into a filtered / transformed map[string][]string output):
463+
// # mutually exclusive with key/valueExpression
464+
// keyAndValueExpression: '{"key":"string-value", "key2": ["value1","value2"]}'
463465
//
464466
// +optional
465467
Extra []ExtraMapping `json:"extra,omitempty"`
466468
}
467469
468470
type ExtraMapping struct {
469-
// Key is a CEL expression to extract extra attribute key.
470-
// Claim must be a singular string claim.
471+
// Key is a string to use as the extra attribute key.
472+
Key string `json:"key"`
473+
// ValueExpression is a CEL expression to extract extra attribute value.
471474
// Expression must produce a string value.
472475
// "" and null values are treated as the extra mapping not being present.
473-
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.
477-
// "", [], and null values are treated as the extra mapping not being present.
478-
Value ClaimOrExpression `json:"value"`
476+
ValueExpression string `json:"valueExpression"`
479477
}
480478
481479
type ClaimOrExpression struct {

0 commit comments

Comments
 (0)