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
OpenID Connect (OIDC) is a simple identity layer on top of the OAuth 2.0 protocol, which allows clients to verify the identity of users based on the authentication performed by an external authorization server. In this guide, we will set up OIDC authentication in kcp using Dex as the identity provider.
9
9
For more details on Kubernetes specific configuration, please refer to this [page](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens).
10
10
11
-
12
11
## Configure kcp OIDC Authentication Using OIDC Flags
13
12
14
13
kcp server will configure the OIDC authentication using the same Kubernetes control plane settings, to start kcp with OIDC authentication enabled, you can simply pass OIDC flags during the start of the kcp server:
15
14
16
15
```bash
17
16
kcp start \
18
-
--oidc-issuer-url=<url of the issuer> \
19
-
--oidc-client-id=<client-id>\
20
-
--oidc-groups-claim=<jwt-claim-name> \
21
-
--oidc-ca-file=<ca-file-path>
17
+
--oidc-issuer-url"<url of the issuer>" \
18
+
--oidc-client-id"<client-id>"\
19
+
--oidc-groups-claim"<jwt-claim-name>" \
20
+
--oidc-ca-file"<ca-file-path>"
22
21
```
23
22
24
-
-`--oidc-issuer-url` URL of the provider that allows the API server to discover public signing keys.
25
-
26
-
-`--oidc-client-id` A client id that all tokens must be issued for.
27
-
28
-
-`--oidc-groups-claim` JWT claim to use as the user's group.
29
-
30
-
-`--oidc-ca-file` The path to the certificate for the CA that signed your identity provider's web certificate.
23
+
-`--oidc-issuer-url` – URL of the provider that allows the API server to discover public signing keys.
24
+
-`--oidc-client-id` – A client ID that all tokens must be issued for.
25
+
-`--oidc-groups-claim` – JWT claim to use as the user's group.
26
+
-`--oidc-ca-file` – The path to the certificate for the CA that signed your identity provider's web certificate.
31
27
32
28
You can also set:
33
29
34
-
-`--oidc-username-claim` JWT claim to use as the user name.
35
-
36
-
-`--oidc-required-claim` A key=value pair that describes a required claim in the ID Token.
37
-
38
-
-`--oidc-signing-algs` The signing algorithms accepted.
39
-
40
-
-`--oidc-username-prefix` Prefix prepended to username claims to prevent clashes with existing names.
41
-
42
-
-`--oidc-groups-prefix` Prefix prepended to group claims to prevent clashes with existing names
30
+
-`--oidc-username-claim` – JWT claim to use as the user name.
31
+
-`--oidc-required-claim` – A key=value pair that describes a required claim in the ID Token.
32
+
-`--oidc-signing-algs` – The signing algorithms accepted.
33
+
-`--oidc-username-prefix` – Prefix prepended to username claims to prevent clashes with existing names.
34
+
-`--oidc-groups-prefix` – Prefix prepended to group claims to prevent clashes with existing names
43
35
44
36
## Configure kcp OIDC Authentication Using Structured Authentication Configuration
45
37
46
38
Alternatively, you can use the beta feature of authentication configuration from a file and set up the kcp server with it.
47
39
Please note that if you specify `--authentication-config` along with any of the `--oidc-*` command line arguments, this will be treated as a misconfiguration.
48
40
49
-
```bash
41
+
```yaml
50
42
apiVersion: apiserver.config.k8s.io/v1beta1
51
43
kind: AuthenticationConfiguration
52
44
# list of authenticators to authenticate Kubernetes users using JWT compliant tokens.
53
45
# the maximum number of allowed authenticators is 64.
54
46
jwt:
55
-
- issuer:
56
-
# url must be unique across all authenticators.
57
-
# url must not conflict with issuer configured in --service-account-issuer.
58
-
url: https://example.com # Same as --oidc-issuer-url.
59
-
# discoveryURL, if specified, overrides the URL used to fetch discovery
60
-
# information instead of using "{url}/.well-known/openid-configuration".
61
-
# The exact value specified is used, so "/.well-known/openid-configuration"
62
-
# must be included in discoveryURL if needed.
63
-
#
64
-
# The "issuer" field in the fetched discovery information must match the "issuer.url" field
65
-
# in the AuthenticationConfiguration and will be used to validate the "iss" claim in the presented JWT.
66
-
# This is for scenarios where the well-known and jwks endpoints are hosted at a different
67
-
# location than the issuer (such as locally in the cluster).
68
-
# discoveryURL must be different from url if specified and must be unique across all authenticators.
message: 'groups cannot used reserved system: prefix'
154
148
```
155
149
156
150
To set up the AuthenticationConfiguration, similarly to the previous example with OIDC flags(`--oidc-issuer-url`, `--oidc-client-id`, `--oidc-groups-claim`, `--oidc-ca-file`), you can set it in the file:
157
151
158
-
```bash
152
+
```yaml
159
153
apiVersion: apiserver.config.k8s.io/v1beta1
160
154
kind: AuthenticationConfiguration
161
155
jwt:
162
-
- issuer:
163
-
url: <url of the issuer>
164
-
certificateAuthority: |
165
-
<ca-file-content>
166
-
audiences:
167
-
- <client-id>
168
-
audienceMatchPolicy: MatchAny
169
-
claimMappings:
170
-
groups:
171
-
claim: <jwt-claim-name>
172
-
prefix: ""
173
-
claimValidationRules: []
174
-
userValidationRules: []
156
+
- issuer:
157
+
url: <url of the issuer>
158
+
certificateAuthority: |
159
+
<ca-file-content>
160
+
audiences:
161
+
- <client-id>
162
+
audienceMatchPolicy: MatchAny
163
+
claimMappings:
164
+
groups:
165
+
claim: <jwt-claim-name>
166
+
prefix: ""
167
+
claimValidationRules: []
168
+
userValidationRules: []
175
169
```
176
170
177
171
To start the kcp server with the specified OIDC authentication configuration, pass the file path to the `--authentication-config` flag.
0 commit comments