You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-auth/3331-structured-config-for-oidc-authentication/README.md
+68-41Lines changed: 68 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,7 +126,7 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
126
126
## Summary
127
127
128
128
This enhancement proposal covers implementing the structured configuration for the OIDC authenticator.
129
-
OIDC authentication is essential part of Kubernetes, yet it has limitations in its current state.
129
+
OIDC authentication is important part of Kubernetes, yet it has limitations in its current state.
130
130
Bellow we will discuss that limitation and propose solutions.
131
131
132
132
# Motivation
@@ -139,11 +139,10 @@ better support various features that have been requested.
139
139
140
140
There are features users want to tune. We need to provide customization of the following:
141
141
142
-
- Claims validation rules: current OIDC provider supports only audience claim validation and only by exact values
143
-
- Claim mappings: it is only possible to pick a single value from a single claim and prefix groups
144
-
- Use more than one OIDC provider: the only option, for now, is to use [Dex](https://dexidp.io/) (or similar software)
145
-
as a lightweight OIDC proxy to connect many providers to Kubernetes
146
-
- Change authenticator settings without restarting kube-apiserver
142
+
-*Claims validation rules*: current OIDC provider supports only audience claim validation and only by exact values.
143
+
-*Claim mappings*: it is only possible to pick a single value from a single claim and prefix groups.
144
+
-*Use more than one OIDC provider*: the only option, for now, is to use an external OIDC provider that handles multiplexing support for multiple providers.
145
+
- Change authenticator settings without restarting kube-apiserver.
147
146
148
147
### Non-Goals
149
148
@@ -171,7 +170,7 @@ The main part of this proposal is a configuration file. It contains an array of
171
170
typeOIDCConfigurationstruct {
172
171
metav1.TypeMeta
173
172
// Providers is a list of OIDC providers to authenticate Kubernetes users.
174
-
Providers []Provider
173
+
Providers []Provider`json:"providers"`
175
174
}
176
175
```
177
176
@@ -180,16 +179,16 @@ Each provider has several properties that will be described in detail below.
180
179
```go
181
180
typeProviderstruct {
182
181
// Issuer is a basic OIDC provider connection options.
183
-
IssuerIssuer
182
+
IssuerIssuer`json:"issuer"`
184
183
// ClaimValidationRules are rules that are applied to validate ID token claims to authorize users.
2. `ClaimValidationRules` - additional rules for authorization.
227
+
2. `ClaimValidationRules` - additional authentication policies. These policies are applied after generic OIDC validations, e.g., checking the token signature, issuer URL, etc. Rules are applicable to distributed claims.
219
228
```go
220
229
type ClaimValidationRule struct {
221
230
// Rule is a logical expression that is written in CEL https://github.com/google/cel-go.
222
-
Rule string
231
+
Rule string `json:"rule"`
223
232
// Message customize returning message for validation error of the particular rule.
224
233
// +optional
225
-
Message string
234
+
Message string `json:"message,omitempty"`
226
235
}
227
236
```
228
237
229
238
For validation expressions, the CEL is used. They are similar to validations functions for [Custom Resources](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#resource-use-by-validation-functions).
230
239
`Rule` expression should always evaluate a boolean. Token `claims` are passed to CEL expressions as a dynamic map `decls.NewMapType(decls.String, decls.Dyn)`.
240
+
241
+
> NOTE: If a rule returns `false` after evaluation, the `401 Unauthorized` error will be returned. If the evaluation is failed in runtime, the `500 Internal Sever Error` error will be returned with a message to kube-apiserver logs.
message: clients other than charmander or bulbasaur are not allowed
239
250
240
-
- rule: 'claims.roles.exists(r, r == "kubernetes-user")'
241
-
message: only kubernetes-user group members can access the cluster
251
+
- rule: 'claims.exp - claims.nbf > 86400'
252
+
message: total token lifetime must not exceed 24 hours
242
253
```
243
254
244
255
3. `ClaimMappings` - rules to map claims from a token to Kubernetes user attributes.
245
256
```go
246
257
type UserAttributes struct {
247
258
// Username represents an option for the username attribute.
248
-
Username string
259
+
Username string `json:"username"`
249
260
// Groups represents an option for the groups attribute.
250
261
// +optional
251
-
Groups string
262
+
Groups string `json:"groups,omitempty"`
252
263
// UID represents an option for the uid attribute.
253
264
// +optional
254
-
UID string
265
+
UID string `json:"uid,omitempty"`
255
266
// Extra represents an option for the extra attribute.
256
267
// +optional
257
-
Extra []ExtraMapping
268
+
Extra []ExtraMapping `json:"extra,omitempty"`
258
269
}
259
270
260
271
type ExtraMapping struct {
261
272
// Key is a CEL expression to extract extra attribute key.
262
-
Key string
263
-
// Expression is a CEL expression to extract extra attribute value.
264
-
Expression string
273
+
Key string `json:"key"`
274
+
// Value is a CEL expression to extract extra attribute value.
275
+
Value string `json:"value"`
265
276
}
266
277
```
267
278
@@ -303,20 +314,30 @@ type Provider struct {
303
314
know the structure of the token and the exact claims they will use in CEL expressions.
304
315
This option helps to reduce system load and operate only with required claims.
305
316
317
+
> TODO: Think about prefixes. The flag-based OIDC authenticator implementation allows to prefix usernames and groups to avoid collisions with system groups or names.
318
+
> 1. This is a common use case. Users can benefit from not using CEL for it.
319
+
> 2. Not only enforcing prefixes is useful. It is also possible to reject tokens if there are groups with the `system:` prefix.
320
+
306
321
### More about CEL
307
322
308
-
* CEL runtime should be compiled only once if structured OIDC config option is enabled
309
-
* To make working with strings more convinient, `strings` and `encoding` [CEL extensions](https://github.com/google/cel-go/tree/v0.9.0/ext) should be enabled,
310
-
e.g, to be able to split a string with comma separated fields and use them as a single array
311
-
* Benchmarks are required to see how different CEL expressions affects authentication time
312
-
* CEL expressions are called on each request. We should properly investigate the influence of these calls on the system
313
-
latency and, if necessary, prove caching or other mechanisms to improve performance.
323
+
* CEL runtime should be compiled only once if structured OIDC config option is enabled.
324
+
* Two variables will be available in to use in rules:
325
+
* `claim` for token claims
326
+
* `now` for the current time in UNIX format to be able to customize the expiration validation (e.g., `Rule: "claims.exp < now", Message: "Token is expired"`)
327
+
* To make working with strings more convenient, `strings` and `encoding` [CEL extensions](https://github.com/google/cel-go/tree/v0.9.0/ext) should be enabled,
328
+
e.g, to be able to split a string with comma separated fields and use them as a single array.
329
+
* Benchmarks are required to see how different CEL expressions affects authentication time.
330
+
* CEL expressions are called on each request. We should properly investigate the influence of these calls on the system.
331
+
latency and, if necessary, prove caching or other mechanisms to improve performance. The possibility of applying caching mechanisms should be considered.
314
332
315
333
### Flags
316
334
317
335
The only flag requires to enable the feature is the `--oidc-configuration-path` flag. It points to the configuration file.
318
336
On startup, kube-apiserver enables the file watcher for the configuration file and reacts to any file change.
319
337
338
+
> NOTE: This KEP is aimed at implementing a new Kubernetes authenticator.
339
+
> It will be possible to simultaneously enable a flag-based OIDC provider authenticator and a structured-config OIDC authenticator.
340
+
320
341
### Test Plan
321
342
322
343
<!--
@@ -334,7 +355,7 @@ when drafting this test plan.
334
355
existing tests to make this code solid enough prior to committing the changes necessary
@@ -403,10 +424,10 @@ We expect no non-infra related flakes in the last month as a GA graduation crite
403
424
404
425
- Gather feedback from developers and surveys
405
426
- Complete benchmarks
427
+
- Add metrics
406
428
407
429
#### GA
408
430
409
-
- Add metrics
410
431
- Add a full documentation with examples for the most popular providers, e.g., Okta, Dex, Auth0
411
432
- Migration guide
412
433
- Deprecation warnings for non-structured OIDC provider configuration
@@ -450,21 +471,27 @@ No.
450
471
451
472
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
452
473
453
-
Yes, but disable means also deleting the flag from the kube-apiserver manifest.
474
+
Yes.
454
475
455
476
###### What happens if we reenable the feature if it was previously rolled back?
456
477
457
478
No impact.
458
479
459
480
###### Are there any tests for feature enablement/disablement?
460
481
461
-
Not required.
482
+
Feature enablement/disablement tests will be added as part of https://github.com/kubernetes/kubernetes/issues/110782
483
+
484
+
> An example test could be: unit test that demonstrates that when the featuregate is false, the validation function on the Options type reports a failure when the flag is set.
462
485
463
486
### Rollout, Upgrade and Rollback Planning
464
487
465
488
###### How can a rollout or rollback fail? Can it impact already running workloads?
466
489
467
-
It cannot fail.
490
+
It cannot fail until a bug in kube-apiserver connected to parsing structured config file occurs.
491
+
492
+
Possible consequences are:
493
+
* A cluster administrator rolls out the feature with the addition of some validation rules that may allow access to previously restricted users.
494
+
* Other cluster components can depend on claim validations. Rolling back would mean losing validation functionality.
468
495
469
496
###### What specific metrics should inform a rollback?
470
497
@@ -530,7 +557,7 @@ These goals will help you determine what you need to measure (SLIs) in the next
530
557
question.
531
558
-->
532
559
533
-
The feature should work 99.9% of the time.
560
+
The feature should work 99.9% of the time (SLOs for actual requests should not change in any way compared to the flag-based OIDC configuration).
534
561
535
562
###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service?
536
563
@@ -629,7 +656,7 @@ TBA.
629
656
630
657
## Drawbacks
631
658
632
-
Nothing can hold us. Everyone agrees that we have to implement this feature to fulfill user expectations.
659
+
- This feature will be the first adoption of using CEL for a config file.
0 commit comments