Skip to content

Commit 4a71e04

Browse files
committed
May 9th pairing session
Signed-off-by: Monis Khan <[email protected]>
1 parent 261a913 commit 4a71e04

File tree

1 file changed

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

1 file changed

+87
-26
lines changed

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

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ If none of those approvers are still appropriate, then changes to that list
5959
should be approved by the remaining approvers and/or the owning SIG (or
6060
SIG Architecture for cross-cutting KEPs).
6161
-->
62-
# KEP-3331: Structured config for OIDC authentication
62+
# KEP-3331: Structured Authentication Config
6363

6464
<!-- toc -->
6565
- [Release Signoff Checklist](#release-signoff-checklist)
@@ -125,16 +125,22 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
125125

126126
## Summary
127127

128-
This enhancement proposal covers implementing the structured configuration for the OIDC authenticator.
129-
OIDC authentication is important part of Kubernetes, yet it has limitations in its current state.
130-
Bellow we will discuss that limitation and propose solutions.
128+
This enhancement proposal covers adding structured authentication configuration to the Kubernetes API server.
129+
Initially, only a `jwt` configuration will be supported, which will serve as the next interation of the existing
130+
OIDC authenticator. OIDC authentication is important part of Kubernetes, yet it has limitations in its current state.
131+
Below we will discuss that limitation and propose solutions.
131132

132133
# Motivation
133134

134135
Structured config for OIDC authentication: noted in various contexts over the past few years. We want to migrate
135136
away from a flag-based config that is growing without bounds to a proper versioned config format. This would allow us to
136137
better support various features that have been requested.
137138

139+
- [Support multiple OIDC ClientIDs on API server](https://github.com/kubernetes/kubernetes/issues/71162)
140+
- OpenID Connect: Identify user by more JWT claims than just a single one kubernetes/kubernetes#71715
141+
- OIDC: Allow any claim from an ID token to be mapped to userinfo extra attributes kubernetes/kubernetes#82236
142+
- Required claims does not support arrays and failing kubernetes auth with oidc - EKS kubernetes/kubernetes#101291
143+
138144
### Goals
139145

140146
There are features users want to tune. We need to provide customization of the following:
@@ -143,14 +149,20 @@ There are features users want to tune. We need to provide customization of the f
143149
- *Claim mappings*: it is only possible to pick a single value from a single claim and prefix groups.
144150
- *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.
145151
- Change authenticator settings without restarting kube-apiserver.
152+
- SPIFFE JWTs
153+
- TODO other issues from the PR
154+
- Validations for infra providers
155+
- Easy migration from existing OIDC flags
146156

147157
### Non-Goals
148158

149-
- Monitoring
159+
- Supporting configuration of authenticaiton mechnisims other than `jwt`
160+
- Supporting other methods for keys discovery other than standart OIDC discovery mechanism
161+
- No support for `x5c`
150162

151163
## Proposal
152164

153-
1. Add new `authentication` API object to parse a structured config file `OIDCConfiguration`.
165+
1. Add new `apiserver.config.k8s.io` API object to parse a structured config file `AuthenticaitonConfiguration`.
154166
2. Add a single flag for kube-apiserver to point to the structured config file, automatically reload it on changes.
155167
3. Use an expression language to let users write their own logic for mappings and validation rules
156168
(expressions should be simple for common cases, yet powerful to cover most user stories).
@@ -164,8 +176,44 @@ we should provide examples of migrating from a flag-based config to a new struct
164176

165177
### Configuration file
166178

179+
TODO:
180+
181+
- we need to define the minimum valid payload
182+
-> iss, exp, iat, and some other field that is the username
183+
-> [oidc validation] -> [claim validation] -> [claim mappings] -> [user info validation] (TODO mermaid diagram)
184+
-> should we have any revocation mechnism?
185+
=> use revocation endpoint if it is in the discovery document? (lets decide what we want here before beta)
186+
167187
The main part of this proposal is a configuration file. It contains an array of providers:
168188

189+
```yaml
190+
apiVersion: apiserver.config.k8s.io/v1alpha1
191+
kind: AuthenticationConfiguration
192+
jwt:
193+
- issuer:
194+
url: https://example.com
195+
clientID: my-app
196+
claimValidationRules:
197+
- rule: 'claims.exp - claims.nbf > 86400'
198+
message: total token lifetime must not exceed 24 hours
199+
claimMappings:
200+
username:
201+
expression: 'claims.username + ":external-user"'
202+
groups:
203+
expression: 'claims.roles.split(",")'
204+
uid:
205+
claim: 'sub'
206+
extra:
207+
- key:
208+
constant: 'client_name' # TODO, decide if we really need this flexiblily or can we just have constant keys
209+
value:
210+
claim: 'aud'
211+
claimFilters:
212+
userInfoValidationRules: # TODO, provide a real world case
213+
214+
```
215+
216+
169217
```go
170218
type OIDCConfiguration struct {
171219
metav1.TypeMeta
@@ -201,6 +249,7 @@ type Provider struct {
201249
// URL points to the issuer URL in a format schema://url/path.
202250
// Not required to be unique because users may want to have the API server trust multiple
203251
// client IDs (kubernetes dashboard, kubectl, etc.) from the same provider.
252+
// Always used for key discovery
204253
URL string `json:"url,omitempty"`
205254
// CertificateAuthorityData contains PEM-encoded certificate authority certificates. Overrides CertificateAuthority.
206255
// +optional
@@ -213,18 +262,28 @@ type Provider struct {
213262
// SkipOIDCValidations is a flag to turn off issuer validation, client id validation.
214263
// OIDC related checks.
215264
//
216-
// Validations that will be skipped:
265+
// Validations that will be skipped (TODO fix this):
217266
// - ClientID validation
218-
// - URL schema equals to HTTPS
267+
// - URL schema equals to HTTPS <-NOT??
219268
// - Issuer URL check
220-
// - Expiry validation
269+
// - Expiry validation <-NOT
221270
//
222271
// +optional
223-
SkipOIDCValidations bool `json:"skipOIDCValidations,omitempty"`
272+
//SkipOIDCValidations bool `json:"skipOIDCValidations,omitempty"`
273+
SkipClientIDValidation bool `json:"skipOIDCValidations,omitempty"`
274+
275+
// If specified, used for the discovery issuer matching and for matching incoming tokens.
276+
IssuerValidationOverride *string `json:"skipOIDCValidations,omitempty"`
224277
}
225278
```
226279
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.
280+
curl oidc.oidc-nameaspace (.url field)
281+
282+
{
283+
issuer: "https://oidc.example.com" (.issuerValidationOverride field)
284+
}
285+
286+
1. `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.
228287
```go
229288
type ClaimValidationRule struct {
230289
// Rule is a logical expression that is written in CEL https://github.com/google/cel-go.
@@ -252,27 +311,32 @@ type Provider struct {
252311
message: total token lifetime must not exceed 24 hours
253312
```
254313
255-
3. `ClaimMappings` - rules to map claims from a token to Kubernetes user attributes.
314+
2. `ClaimMappings` - rules to map claims from a token to Kubernetes user attributes.
256315
```go
257316
type UserAttributes struct {
258317
// Username represents an option for the username attribute.
259-
Username string `json:"username"`
318+
Username KeyOrExpression `json:"username"`
260319
// Groups represents an option for the groups attribute.
261320
// +optional
262-
Groups string `json:"groups,omitempty"`
321+
Groups KeyOrExpression `json:"groups,omitempty"`
263322
// UID represents an option for the uid attribute.
264323
// +optional
265-
UID string `json:"uid,omitempty"`
324+
UID KeyOrExpression `json:"uid,omitempty"`
266325
// Extra represents an option for the extra attribute.
267326
// +optional
268327
Extra []ExtraMapping `json:"extra,omitempty"`
269328
}
270329
271330
type ExtraMapping struct {
272331
// Key is a CEL expression to extract extra attribute key.
273-
Key string `json:"key"`
332+
Key KeyOrExpression `json:"key"`
274333
// Value is a CEL expression to extract extra attribute value.
275-
Value string `json:"value"`
334+
Value KeyOrExpression `json:"value"`
335+
}
336+
337+
type KeyOrExpression struct {
338+
Key string `json:"key"`
339+
Expression string `json:"value"`
276340
}
277341
```
278342
@@ -310,7 +374,7 @@ type Provider struct {
310374
extra:
311375
client_name: kubernetes
312376
```
313-
4. `ClaimsFilter` - list of claim names that should be passed to CEL expressions. The assumption is that administrators
377+
3. `ClaimsFilter` - list of claim names that should be passed to CEL expressions. The assumption is that administrators
314378
know the structure of the token and the exact claims they will use in CEL expressions.
315379
This option helps to reduce system load and operate only with required claims.
316380
@@ -503,7 +567,7 @@ Yes. It works.
503567

504568
###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
505569

506-
Yes, the `--oidc-configuration-path` flag should be removed from the kube-apiserver manifest.
570+
Yes, the `--authentication-config` flag should be removed from the kube-apiserver manifest.
507571

508572
### Monitoring Requirements
509573

@@ -532,13 +596,10 @@ and operation of this feature.
532596
Recall that end users cannot usually observe component logs or access metrics.
533597
-->
534598

535-
- [ ] Events
536-
- Event Reason:
537-
- [ ] API .status
538-
- Condition name:
539-
- Other field:
540-
- [ ] Other (treat as last resort)
541-
- Details:
599+
Metrics
600+
601+
- Last successful load of the file
602+
- Last time keys were fetched (would be per issuer)
542603

543604
###### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
544605

0 commit comments

Comments
 (0)