Skip to content

Commit 28a2e98

Browse files
lmktfywindsonseaRitikaa96
committed
Reword explanation of external authn integrations
Co-authored-by: Michael Yao <[email protected]> Co-authored-by: Ritika <[email protected]>
1 parent eb5bc5d commit 28a2e98

File tree

1 file changed

+132
-62
lines changed

1 file changed

+132
-62
lines changed

content/en/docs/reference/access-authn-authz/authentication.md

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ The API server does not guarantee the order authenticators run in.
7575

7676
The `system:authenticated` group is included in the list of groups for all authenticated users.
7777

78-
Integrations with other authentication protocols (LDAP, SAML, Kerberos, alternate x509 schemes, etc)
79-
can be accomplished using an [authenticating proxy](#authenticating-proxy) or the
78+
[Integrations](#external-integrations) with other authentication protocols (LDAP, SAML, Kerberos, alternate x509 schemes, etc)
79+
are available; for example using an [authenticating proxy](#authenticating-proxy) or the
8080
[authentication webhook](#webhook-token-authentication).
8181

82-
### X509 client certificates
82+
### X.509 client certificates {#x509-client-certificates}
8383

8484
Client certificate authentication is enabled by passing the `--client-ca-file=SOMEFILE`
8585
option to API server. The referenced file must contain one or more certificate authorities
@@ -99,23 +99,6 @@ This would create a CSR for the username "jbeda", belonging to two groups, "app1
9999

100100
See [Managing Certificates](/docs/tasks/administer-cluster/certificates/) for how to generate a client cert.
101101

102-
### Static token file
103-
104-
The API server reads bearer tokens from a file when given the `--token-auth-file=SOMEFILE` option
105-
on the command line. Currently, tokens last indefinitely, and the token list cannot be
106-
changed without restarting the API server.
107-
108-
The token file is a csv file with a minimum of 3 columns: token, user name, user uid,
109-
followed by optional group names.
110-
111-
{{< note >}}
112-
If you have more than one group, the column must be double quoted e.g.
113-
114-
```conf
115-
token,user,uid,"group1,group2,group3"
116-
```
117-
{{< /note >}}
118-
119102
#### Putting a bearer token in a request
120103

121104
When using bearer token authentication from an http client, the API
@@ -246,7 +229,24 @@ Secrets can authenticate as the service account. Be cautious when granting permi
246229
to service accounts and read or write capabilities for Secrets.
247230
{{< /warning >}}
248231

249-
### OpenID Connect Tokens
232+
## External integrations
233+
234+
Kubernetes has native support for OpenID Connect (OIDC); see [OpenID Connect tokens](#openid-connect-tokens).
235+
236+
Integrations with other authentication protocols (for example: LDAP, SAML, Kerberos, alternate X.509 schemes)
237+
can be accomplished using an [authenticating proxy](#authenticating-proxy) or by integrating with an
238+
[authentication webhook](#webhook-token-authentication).
239+
240+
You can also use any custom method that issues [client X.509 certificates](#x509-client-certificates) to clients,
241+
provided that the API server will trust the valid certificates.
242+
Read [X.509 client certificates](#x509-client-certificates) to learn about how to generate a
243+
certificate.
244+
245+
If you do issue certificates to clients, it is up to you (as a cloud platform administrator)
246+
to make sure that the certicate validity period, and other design choices you make, provide a
247+
suitable level of security.
248+
249+
### OpenID Connect tokens
250250

251251
[OpenID Connect](https://openid.net/connect/) is a flavor of OAuth2 supported by
252252
some OAuth2 providers, notably Microsoft Entra ID, Salesforce, and Google.
@@ -290,7 +290,7 @@ sequenceDiagram
290290

291291
1. Log in to your identity provider
292292
1. Your identity provider will provide you with an `access_token`, `id_token` and a `refresh_token`
293-
1. When using `kubectl`, use your `id_token` with the `--token` flag or add it directly to your `kubeconfig`
293+
1. When using `kubectl`, use your `id_token` with the `--token` command line argument or add it directly to your `kubeconfig`
294294
1. `kubectl` sends your `id_token` in a header called Authorization to the API server
295295
1. The API server will make sure the JWT signature is valid
296296
1. Check to make sure the `id_token` hasn't expired
@@ -323,10 +323,10 @@ To enable the plugin, configure the following flags on the API server:
323323
| `--oidc-issuer-url` | URL of the provider that allows the API server to discover public signing keys. Only URLs that use the `https://` scheme are accepted. This is typically the provider's discovery URL, changed to have an empty path. | If the issuer's OIDC discovery URL is `https://accounts.provider.example/.well-known/openid-configuration`, the value should be `https://accounts.provider.example` | Yes |
324324
| `--oidc-client-id` | A client id that all tokens must be issued for. | kubernetes | Yes |
325325
| `--oidc-username-claim` | JWT claim to use as the user name. By default `sub`, which is expected to be a unique identifier of the end user. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent naming clashes with other plugins. | sub | No |
326-
| `--oidc-username-prefix` | Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag isn't provided and `--oidc-username-claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `--oidc-issuer-url`. The value `-` can be used to disable all prefixing. | `oidc:` | No |
326+
| `--oidc-username-prefix` | Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this argument isn't provided and `--oidc-username-claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `--oidc-issuer-url`. The value `-` can be used to disable all prefixing. | `oidc:` | No |
327327
| `--oidc-groups-claim` | JWT claim to use as the user's group. If the claim is present it must be an array of strings. | groups | No |
328328
| `--oidc-groups-prefix` | Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`. | `oidc:` | No |
329-
| `--oidc-required-claim` | A key=value pair that describes a required claim in the ID Token. If set, the claim is verified to be present in the ID Token with a matching value. Repeat this flag to specify multiple claims. | `claim=value` | No |
329+
| `--oidc-required-claim` | A key=value pair that describes a required claim in the ID Token. If set, the claim is verified to be present in the ID Token with a matching value. Repeat this argument to specify multiple claims. | `claim=value` | No |
330330
| `--oidc-ca-file` | The path to the certificate for the CA that signed your identity provider's web certificate. Defaults to the host's root CAs. | `/etc/kubernetes/ssl/kc-ca.pem` | No |
331331
| `--oidc-signing-algs` | The signing algorithms accepted. Default is RS256. Allowed values are: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512. Values are defined by RFC 7518 https://tools.ietf.org/html/rfc7518#section-3.1. | `RS512` | No |
332332

@@ -356,8 +356,7 @@ The API server also automatically reloads the authenticators when the configurat
356356
You can use `apiserver_authentication_config_controller_automatic_reload_last_timestamp_seconds` metric
357357
to monitor the last time the configuration was reloaded by the API server.
358358

359-
You must specify the path to the authentication configuration using the `--authentication-config` flag
360-
on the API server. If you want to use command line flags instead of the configuration file, those will
359+
You must specify the path to the authentication configuration using the `--authentication-config` command line argument to the API server. If you want to use command line arguments instead of the configuration file, those will
361360
continue to work as-is. To access the new capabilities like configuring multiple authenticators,
362361
setting multiple audiences for an issuer, switch to using the configuration file.
363362

@@ -375,13 +374,7 @@ If you want to switch to using structured authentication configuration, you have
375374
command line arguments, and use the configuration file instead.
376375
{{< /note >}}
377376

378-
{{< feature-state feature_gate_name="StructuredAuthenticationConfigurationEgressSelector" >}}
379-
380-
The _egressSelectorType_ field in the JWT issuer configuration allows you to specify which egress selector
381-
should be used for sending all traffic related to the issuer (discovery, JWKS, distributed claims, etc).
382-
This feature requires the `StructuredAuthenticationConfigurationEgressSelector` feature gate to be enabled.
383-
384-
```yaml
377+
{{< highlight yaml "linenos=false,hl_lines=2-5" >}}
385378
---
386379
#
387380
# CAUTION: this is an example configuration.
@@ -409,7 +402,7 @@ jwt:
409402
discoveryURL: https://discovery.example.com/.well-known/openid-configuration
410403
# PEM encoded CA certificates used to validate the connection when fetching
411404
# discovery information. If not set, the system verifier will be used.
412-
# Same value as the content of the file referenced by the --oidc-ca-file flag.
405+
# Same value as the content of the file referenced by the --oidc-ca-file command line argument.
413406
certificateAuthority: <PEM encoded CA certificates>
414407
# audiences is the set of acceptable audiences the JWT must be issued to.
415408
# At least one of the entries must match the "aud" claim in presented JWTs.
@@ -420,6 +413,8 @@ jwt:
420413
audienceMatchPolicy: MatchAny
421414
# egressSelectorType is an indicator of which egress selection should be used for sending all traffic related
422415
# to this issuer (discovery, JWKS, distributed claims, etc). If unspecified, no custom dialer is used.
416+
# The StructuredAuthenticationConfigurationEgressSelector feature gate must be enabled
417+
# before you can use the egressSelectorType field.
423418
# When specified, the valid choices are "controlplane" and "cluster". These correspond to the associated
424419
# values in the --egress-selector-config-file.
425420
# - controlplane: for traffic intended to go to the control plane.
@@ -498,7 +493,7 @@ jwt:
498493
message: 'username cannot used reserved system: prefix'
499494
- expression: "user.groups.all(group, !group.startsWith('system:'))"
500495
message: 'groups cannot used reserved system: prefix'
501-
```
496+
{{< /highlight >}}
502497

503498
* Claim validation rule expression
504499

@@ -707,7 +702,15 @@ jwt:
707702
{{% /tab %}}
708703
{{< /tabs >}}
709704

710-
###### Limitations
705+
##### JWT egress selector type
706+
707+
{{< feature-state feature_gate_name="StructuredAuthenticationConfigurationEgressSelector" >}}
708+
709+
The _egressSelectorType_ field in the JWT issuer configuration allows you to specify which egress selector
710+
should be used for sending all traffic related to the issuer (discovery, JWKS, distributed claims, etc).
711+
This feature requires the `StructuredAuthenticationConfigurationEgressSelector` feature gate to be enabled.
712+
713+
##### Limitations {#oidc-limitations}
711714

712715
1. Distributed claims do not work via [CEL](/docs/reference/using-api/cel/) expressions.
713716

@@ -736,14 +739,14 @@ standard certificate generation tools.
736739

737740
#### Using kubectl
738741

739-
##### Option 1 - OIDC Authenticator
742+
##### Option 1 - OIDC authenticator
740743

741744
The first option is to use the kubectl `oidc` authenticator, which sets the `id_token` as a bearer token
742745
for all requests and refreshes the token once it expires. After you've logged into your provider, use
743746
kubectl to add your `id_token`, `refresh_token`, `client_id`, and `client_secret` to configure the plugin.
744747

745748
Providers that don't return an `id_token` as part of their refresh token response aren't supported
746-
by this plugin and should use "Option 2" below.
749+
by this plugin and should use [Option 2](#option-2-use-the-token-option) (specifying `--token`).
747750

748751
```bash
749752
kubectl config set-credentials USER_NAME \
@@ -789,18 +792,21 @@ users:
789792
Once your `id_token` expires, `kubectl` will attempt to refresh your `id_token` using your `refresh_token`
790793
and `client_secret` storing the new values for the `refresh_token` and `id_token` in your `.kube/config`.
791794

792-
##### Option 2 - Use the `--token` Option
795+
##### Option 2 - Use the `--token` command line argument {#option-2-use-the-token-option}
793796

794-
The `kubectl` command lets you pass in a token using the `--token` option.
797+
The `kubectl` command lets you pass in a token using the `--token` command line argument.
795798
Copy and paste the `id_token` into this option:
796799

797800
```bash
798801
kubectl --token=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL21sYi50cmVtb2xvLmxhbjo4MDQzL2F1dGgvaWRwL29pZGMiLCJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNDc0NTk2NjY5LCJqdGkiOiI2RDUzNXoxUEpFNjJOR3QxaWVyYm9RIiwiaWF0IjoxNDc0NTk2MzY5LCJuYmYiOjE0NzQ1OTYyNDksInN1YiI6Im13aW5kdSIsInVzZXJfcm9sZSI6WyJ1c2VycyIsIm5ldy1uYW1lc3BhY2Utdmlld2VyIl0sImVtYWlsIjoibXdpbmR1QG5vbW9yZWplZGkuY29tIn0.f2As579n9VNoaKzoF-dOQGmXkFKf1FMyNV0-va_B63jn-_n9LGSCca_6IVMP8pO-Zb4KvRqGyTP0r3HkHxYy5c81AnIh8ijarruczl-TK_yF5akjSTHFZD-0gRzlevBDiH8Q79NAr-ky0P4iIXS8lY9Vnjch5MF74Zx0c3alKJHJUnnpjIACByfF2SCaYzbWFMUNat-K1PaUk5-ujMBG7yYnr95xD-63n8CO8teGUAAEMx6zRjzfhnhbzX-ajwZLGwGUBT4WqjMs70-6a7_8gZmLZb2az1cZynkFRj2BaCkVT3A2RrjeEwZEtGXlMqKJ1_I2ulrOVsYx01_yD35-rw get nodes
799802
```
800803

801-
### Webhook Token Authentication
802804

803-
Webhook authentication is a hook for verifying bearer tokens.
805+
### Webhook token authentication
806+
807+
Kubernetes _webhook authentication_ is a mechanism to make an HTTP callout for verifying bearer tokens.
808+
809+
In terms of how you configure the API server:
804810

805811
* `--authentication-token-webhook-config-file` a configuration file describing how to access the remote webhook service.
806812
* `--authentication-token-webhook-cache-ttl` how long to cache authentication decisions. Defaults to two minutes.
@@ -1002,25 +1008,53 @@ An unsuccessful request would return:
10021008
{{% /tab %}}
10031009
{{< /tabs >}}
10041010

1005-
### Authenticating Proxy
1011+
### Authenticating reverse proxy {#authenticating-proxy}
1012+
1013+
{{< warning >}}
1014+
If you have a certificate authority (CA) that is also used in a different context, **do not** trust
1015+
that certificate authority to identify authenticating proxy clients, unless you understand the
1016+
risks and the mechanisms to protect that CA's usage.
1017+
{{< /warning >}}
10061018

10071019
The API server can be configured to identify users from request header values, such as `X-Remote-User`.
1008-
It is designed for use in combination with an authenticating proxy, which sets the request header value.
1009-
1010-
* `--requestheader-username-headers` Required, case-insensitive. Header names to check, in order,
1011-
for the user identity. The first header containing a value is used as the username.
1012-
* `--requestheader-group-headers` 1.6+. Optional, case-insensitive. "X-Remote-Group" is suggested.
1013-
Header names to check, in order, for the user's groups. All values in all specified headers are used as group names.
1014-
* `--requestheader-extra-headers-prefix` 1.6+. Optional, case-insensitive. "X-Remote-Extra-" is suggested.
1015-
Header prefixes to look for to determine extra information about the user (typically used by the configured authorization plugin).
1020+
It is designed for use in combination with an _authenticating proxy_ that sets these headers.
1021+
1022+
The command line arguments to configure this mode are:
1023+
1024+
<!-- trailing whitespace (exactly two spaces) is significant in the following list -->
1025+
1026+
`--requestheader-client-ca-file`
1027+
: _Required._
1028+
Path to a PEM-encoded certificate bundle.
1029+
A valid [client certificate](#reverse-proxy-client-certificate)
1030+
must be presented and validated against the certificate authorities in the specified file before the
1031+
request headers are checked for user names.
1032+
1033+
`--requestheader-allowed-names`
1034+
: _Optional._ Comma-separated list of Common Name values (CNs).
1035+
If set, a valid client
1036+
certificate with a CN in the specified list must be presented before the request headers are checked
1037+
for user names. If empty, any CN is allowed.
1038+
1039+
`--requestheader-username-headers`
1040+
: _Required; case-insensitive._ Header names to check, in order, for the user identity.
1041+
The first header containing a value is used as the username.
1042+
1043+
`--requestheader-group-headers`
1044+
: _Optional; case-insensitive._
1045+
Header names to check, in order, for the user's groups.
1046+
`X-Remote-Group` is suggested.
1047+
All values in all specified headers are used as group names.
1048+
1049+
`--requestheader-extra-headers-prefix`
1050+
: _Optional; case-insensitive._
1051+
Header prefixes to look for to determine extra information about the user.
1052+
`X-Remote-Extra-` is suggested.
1053+
Extra data is typically used by the configured authorization plugin(s).
10161054
Any headers beginning with any of the specified prefixes have the prefix removed.
10171055
The remainder of the header name is lowercased and [percent-decoded](https://tools.ietf.org/html/rfc3986#section-2.1)
10181056
and becomes the extra key, and the header value is the extra value.
10191057

1020-
{{< note >}}
1021-
Prior to 1.11.3 (and 1.10.7, 1.9.11), the extra key could only contain characters which
1022-
were [legal in HTTP header labels](https://tools.ietf.org/html/rfc7230#section-3.2.6).
1023-
{{< /note >}}
10241058

10251059
For example, with this configuration:
10261060

@@ -1057,17 +1091,53 @@ extra:
10571091
- profile
10581092
```
10591093
1094+
{{< note >}}
1095+
Prior to Kubernetes 1.11.3 (and 1.10.7, 1.9.11), the `extra` key could only contain characters that
1096+
were [legal in HTTP header labels](https://tools.ietf.org/html/rfc7230#section-3.2.6).
1097+
{{< /note >}}
1098+
1099+
#### Client certificate {#reverse-proxy-client-certificate}
1100+
10601101
In order to prevent header spoofing, the authenticating proxy is required to present a valid client
10611102
certificate to the API server for validation against the specified CA before the request headers are
1062-
checked. WARNING: do **not** reuse a CA that is used in a different context unless you understand
1103+
checked.
1104+
1105+
<!-- deliberately repeating the earlier warning -->
1106+
Do **not** reuse a CA that is used in a different context unless you understand
10631107
the risks and the mechanisms to protect the CA's usage.
10641108

1065-
* `--requestheader-client-ca-file` Required. PEM-encoded certificate bundle. A valid client certificate
1066-
must be presented and validated against the certificate authorities in the specified file before the
1067-
request headers are checked for user names.
1068-
* `--requestheader-allowed-names` Optional. List of Common Name values (CNs). If set, a valid client
1069-
certificate with a CN in the specified list must be presented before the request headers are checked
1070-
for user names. If empty, any CN is allowed.
1109+
### Static token file integration {#static-token-file}
1110+
1111+
The API server reads static bearer tokens from a file when given the `--token-auth-file=<SOMEFILE>`
1112+
option on the command line.
1113+
In Kubernetes {{< skew currentVersion >}}, tokens last indefinitely, and the token list cannot be
1114+
changed without restarting the API server.
1115+
1116+
The token file is a CSV file with a minimum of 3 columns: token, user name, user uid,
1117+
followed by a comma-separated list of optional group names.
1118+
1119+
1120+
{{< note >}}
1121+
If you have more than one group, the column must be double quoted e.g.
1122+
1123+
```conf
1124+
token,user,uid,"group1,group2,group3"
1125+
```
1126+
{{< /note >}}
1127+
1128+
Using a static token file is appropriate for tokens that by their nature
1129+
are long-lived, static, and perhaps may never be rotated. It is also useful
1130+
when the client is local to a particular API server within the control plane,
1131+
such as a monitoring agent.
1132+
1133+
If you use this method during cluster provisioning, and then transition to
1134+
a different authentication method that will be used longer term, you
1135+
should deactivate the token that was used for bootstrapping (this requires
1136+
a restart of each API server.
1137+
1138+
For other circumstances, and especially where very prompt token rotation is
1139+
important, the Kubernetes project recommends using a
1140+
[webhook token authenticator](#webhook-token-authentication) instead of this mechanism.
10711141

10721142
## Anonymous requests
10731143

0 commit comments

Comments
 (0)