Skip to content

Commit d67e0ce

Browse files
authored
Merge pull request #4562 from aramase/aramase/c/kep_3331_beta_impl_update
KEP-3331: update kep with beta implementation
2 parents e8045cf + 2fb5a58 commit d67e0ce

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

keps/sig-auth/3331-structured-authentication-configuration/README.md

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ with the existing OIDC flags, so we will provide documentation for migrating fro
129129
The main part of this proposal is a configuration file. It contains an array of providers:
130130

131131
```yaml
132-
apiVersion: apiserver.config.k8s.io/v1alpha1
132+
apiVersion: apiserver.config.k8s.io/v1beta1
133133
kind: AuthenticationConfiguration
134134
jwt:
135135
- issuer:
@@ -162,18 +162,13 @@ jwt:
162162
message: groups cannot used reserved system: prefix
163163
```
164164
165-
The minimum valid payload from a JWT is (`aud` may be a `string`):
166-
167-
```json
165+
The minimum valid JWT payload must contain the following claims:
166+
```yaml
168167
{
169-
"iss": "https://example.com",
170-
"sub": "001",
171-
"aud": [
172-
"cluster-a"
173-
],
174-
"exp": 1684274031,
175-
"iat": 1684270431,
176-
"nbf": 1684270431
168+
"iss": "https://example.com", // must match the issuer.url
169+
"aud": ["my-app"], // at least one of the entries in issuer.audiences must match the "aud" claim in presented JWTs.
170+
"exp": 1234567890, // token expiration as Unix time (the number of seconds elapsed since January 1, 1970 UTC)
171+
"<username-claim>": "user" // this is the username claim configured in the claimMappings.username.claim or claimMappings.username.expression
177172
}
178173
```
179174

@@ -254,35 +249,43 @@ type JWTAuthenticator struct {
254249

255250
```go
256251
type Issuer struct {
257-
// url points to the issuer URL in a format https://url/path.
252+
// url points to the issuer URL in a format https://url or https://url/path.
258253
// This must match the "iss" claim in the presented JWT, and the issuer returned from discovery.
259254
// Same value as the --oidc-issuer-url flag.
260-
// Used to fetch discovery information unless overridden by discoveryURL.
261-
// Required to be unique.
255+
// Discovery information is fetched from "{url}/.well-known/openid-configuration" unless overridden by discoveryURL.
256+
// Required to be unique across all JWT authenticators.
262257
// Note that egress selection configuration is not used for this network connection.
263258
// TODO: decide if we want to support egress selection configuration and how to do so.
264259
URL string `json:"url"`
265260

266-
// discoveryURL if specified, overrides the URL used to fetch discovery information.
261+
// discoveryURL, if specified, overrides the URL used to fetch discovery
262+
// information instead of using "{url}/.well-known/openid-configuration".
263+
// The exact value specified is used, so "/.well-known/openid-configuration"
264+
// must be included in discoveryURL if needed.
265+
//
266+
// The "issuer" field in the fetched discovery information must match the "issuer.url" field
267+
// in the AuthenticationConfiguration and will be used to validate the "iss" claim in the presented JWT.
267268
// This is for scenarios where the well-known and jwks endpoints are hosted at a different
268269
// location than the issuer (such as locally in the cluster).
269-
// Format must be https://url/path.
270270
//
271271
// Example:
272-
// A discovery url that is exposed using kubernetes service 'oidc' in namespace 'oidc-namespace'.
272+
// A discovery url that is exposed using kubernetes service 'oidc' in namespace 'oidc-namespace'
273+
// and discovery information is available at '/.well-known/openid-configuration'.
274+
// discoveryURL: "https://oidc.oidc-namespace/.well-known/openid-configuration"
273275
// certificateAuthority is used to verify the TLS connection and the hostname on the leaf certificate
274276
// must be set to 'oidc.oidc-namespace'.
275277
//
276-
// curl https://oidc.oidc-namespace (.discoveryURL field)
278+
// curl https://oidc.oidc-namespace/.well-known/openid-configuration (.discoveryURL field)
277279
// {
278280
// issuer: "https://oidc.example.com" (.url field)
279281
// }
280282
//
281-
// Required to be unique.
283+
// discoveryURL must be different from url.
284+
// Required to be unique across all JWT authenticators.
282285
// Note that egress selection configuration is not used for this network connection.
283286
// TODO: decide if we want to support egress selection configuration and how to do so.
284287
// +optional
285-
DiscoveryURL *string `json:"discoveryURL,omitempty"`
288+
DiscoveryURL string `json:"discoveryURL,omitempty"`
286289

287290
// certificateAuthority contains PEM-encoded certificate authority certificates
288291
// used to validate the connection when fetching discovery information.
@@ -373,6 +376,10 @@ type JWTAuthenticator struct {
373376
// (2) if userName.prefix = "" and userName.claim != "email", prefix will be "<issuer.url>#"
374377
// (3) if userName.expression is set instead, result of expression is used as-is without any implicit prefix
375378
// (1) and (2) ensure backward compatibility with the --oidc-username-claim and --oidc-username-prefix flags
379+
// If username.expression uses 'claims.email', then 'claims.email_verified' must be used in
380+
// username.expression or extra[*].valueExpression or claimValidationRules[*].expression.
381+
// An example claim validation rule expression that matches the validation automatically
382+
// applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true)'.
376383
// +required
377384
Username PrefixedClaimOrExpression `json:"username"`
378385
// groups represents an option for the groups attribute.
@@ -817,7 +824,7 @@ New metrics:
817824
- `apiserver_authentication_config_controller_automatic_reload_last_timestamp_seconds` - This metric will be updated every time the API server reloads the configuration file.
818825
- `apiserver_authentication_config_controller_automatic_reloads_total` - This metric will be incremented every time the API server reloads the configuration file partitioned by status (success/failure).
819826
- `apiserver_authentication_config_controller_automatic_reload_last_config_hash` - This metric will be set to the hash of the loaded configuration file after a successful reload.
820-
- `apiserver_authentication_latency_seconds` - This metric will be used to monitor the time it takes to Authenticate token. This will only be set for token authentication requests for matching issuer.
827+
- `apiserver_authentication_jwt_authenticator_latency_seconds` - This metric will be used to monitor the time it takes to Authenticate token. This will only be set for token authentication requests for matching issuer.
821828
- `apiserver_authentication_jwks_fetch_last_timestamp_seconds` - This metric will be updated every time the API server makes a request to the JWKS endpoint.
822829
- `apiserver_authentication_jwks_fetch_last_keyset_hash` - This metric will be set to the hash of the keyset fetched from the JWKS endpoint after successfully fetching the keyset.
823830
- We will use https://pkg.go.dev/hash/fnv#New64 to hash the keyset.

keps/sig-auth/3331-structured-authentication-configuration/kep.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ metrics:
2626
- apiserver_authentication_config_controller_automatic_reload_last_timestamp_seconds{status, apiserver_id_hash}
2727
- apiserver_authentication_config_controller_automatic_reload_last_config_hash{apiserver_id_hash}
2828
- apiserver_authentication_config_controller_automatic_reloads_total{apiserver_id_hash,status}
29-
- apiserver_authentication_latency_seconds{apiserver_id_hash,jwt_issuer_hash}
29+
- apiserver_authentication_jwt_authenticator_latency_seconds{jwt_issuer_hash}
3030
- apiserver_authentication_jwks_fetch_last_timestamp_seconds{apiserver_id_hash,jwt_issuer_hash,status}
3131
- apiserver_authentication_jwks_fetch_last_keyset_hash{apiserver_id_hash,jwt_issuer_hash}
3232
- apiserver_authentication_jwt_authenticator_provider_status_timestamp_seconds{apiserver_id_hash,jwt_issuer_hash,status}

0 commit comments

Comments
 (0)