Skip to content

Commit 64a99ef

Browse files
committed
[zh-cn]sync authentication.md
Signed-off-by: xin.li <[email protected]>
1 parent 6158937 commit 64a99ef

File tree

1 file changed

+96
-10
lines changed

1 file changed

+96
-10
lines changed

content/zh-cn/docs/reference/access-authn-authz/authentication.md

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,23 @@ talk to the API server. Accounts may be explicitly associated with pods using th
348348
{{< /note >}}
349349

350350
<!--
351-
# this apiVersion is relevant as of Kubernetes 1.9
351+
```yaml
352+
apiVersion: apps/v1 # this apiVersion is relevant as of Kubernetes 1.9
353+
kind: Deployment
354+
metadata:
355+
name: nginx-deployment
356+
namespace: default
357+
spec:
358+
replicas: 3
359+
template:
360+
metadata:
361+
# ...
362+
spec:
363+
serviceAccountName: bob-the-bot
364+
containers:
365+
- name: nginx
366+
image: nginx:1.14.2
367+
```
352368
-->
353369
```yaml
354370
apiVersion: apps/v1 # 此 apiVersion 从 Kubernetes 1.9 开始可用
@@ -570,7 +586,7 @@ To enable the plugin, configure the following flags on the API server:
570586
| `--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 |
571587
| `--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 |
572588
| `--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 |
573-
| `--oidc-signing-algs` | The signing algorithms accepted. Default is "RS256". | `RS512` | No |
589+
| `--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 |
574590
-->
575591

576592
| 参数 | 描述 | 示例 | 必需? |
@@ -583,7 +599,7 @@ To enable the plugin, configure the following flags on the API server:
583599
| `--oidc-groups-prefix` | 添加到组申领的前缀,用来避免与现有用户组名(如:`system:` 组)发生冲突。例如,此标志值为 `oidc:` 时,所得到的用户组名形如 `oidc:engineering` 和 `oidc:infra`。 | `oidc:` | 否 |
584600
| `--oidc-required-claim` | 取值为一个 key=value 偶对,意为 ID 令牌中必须存在的申领。如果设置了此标志,则 ID 令牌会被检查以确定是否包含取值匹配的申领。此标志可多次重复,以指定多个申领。 | `claim=value` | 否 |
585601
| `--oidc-ca-file` | 指向一个 CA 证书的路径,该 CA 负责对你的身份服务的 Web 证书提供签名。默认值为宿主系统的根 CA。 | `/etc/kubernetes/ssl/kc-ca.pem` | 否 |
586-
| `--oidc-signing-algs` | 采纳的签名算法。默认为 "RS256"。 | `RS512` | 否 |
602+
| `--oidc-signing-algs` | 采纳的签名算法。默认为 "RS256"。可选值为:RS256、RS384、RS512、ES256、ES384、ES512、PS256、PS384、PS512。值由 RFC 7518 https://tools.ietf.org/html/rfc7518#section-3.1 定义。| `RS512` | 否 |
587603

588604
<!--
589605
##### Authentication configuration from a file {#using-authentication-configuration}
@@ -889,7 +905,7 @@ jwt:
889905
# expression 是一个计算结果为布尔值的 CEL 表达式。
890906
# 所有表达式的计算结果必须为 true,用户才有效。
891907
- expression: "!user.username.startsWith('system:')"
892-
# Message 自定义验证失败时在 API 服务器日志中看到的错误消息。
908+
# message 是自定义验证失败时在 API 服务器日志中看到的错误消息。
893909
message: 'username cannot used reserved system: prefix'
894910
- expression: "user.groups.all(group, !group.startsWith('system:'))"
895911
message: 'groups cannot used reserved system: prefix'
@@ -943,16 +959,38 @@ jwt:
943959

944960
Here are examples of the `AuthenticationConfiguration` with different token payloads.
945961
-->
946-
要了解更多信息,请参阅[CEL 文档](/docs/reference/using-api/cel/)。
962+
要了解更多信息,请参阅 [CEL 文档](/zh-cn/docs/reference/using-api/cel/)。
947963

948964
以下是具有不同令牌有效负载的 “AuthenticationConfiguration” 示例。
949965

950966

951967
{{< tabs name="example_configuration" >}}
952968
{{% tab name="Valid token" %}}
953969
<!--
954-
# the expression will evaluate to true, so validation will succeed.
970+
```yaml
971+
apiVersion: apiserver.config.k8s.io/v1beta1
972+
kind: AuthenticationConfiguration
973+
jwt:
974+
- issuer:
975+
url: https://example.com
976+
audiences:
977+
- my-app
978+
claimMappings:
979+
username:
980+
expression: 'claims.username + ":external-user"'
981+
groups:
982+
expression: 'claims.roles.split(",")'
983+
uid:
984+
expression: 'claims.sub'
985+
extra:
986+
- key: 'example.com/tenant'
987+
valueExpression: 'claims.tenant'
988+
userValidationRules:
989+
- expression: "!user.username.startsWith('system:')" # the expression will evaluate to true, so validation will succeed.
990+
message: 'username cannot used reserved system: prefix'
991+
```
955992
-->
993+
956994
```yaml
957995
apiVersion: apiserver.config.k8s.io/v1beta1
958996
kind: AuthenticationConfiguration
@@ -1022,8 +1060,32 @@ jwt:
10221060
{{% /tab %}}
10231061
{{% tab name="Fails claim validation" %}}
10241062
<!--
1025-
# the token below does not have this claim, so validation will fail.
1026-
# the expression will evaluate to true, so validation will succeed.
1063+
```yaml
1064+
apiVersion: apiserver.config.k8s.io/v1beta1
1065+
kind: AuthenticationConfiguration
1066+
jwt:
1067+
- issuer:
1068+
url: https://example.com
1069+
audiences:
1070+
- my-app
1071+
claimValidationRules:
1072+
- expression: 'claims.hd == "example.com"' # the token below does not have this claim, so validation will fail.
1073+
message: the hd claim must be set to example.com
1074+
claimMappings:
1075+
username:
1076+
expression: 'claims.username + ":external-user"'
1077+
groups:
1078+
expression: 'claims.roles.split(",")'
1079+
uid:
1080+
expression: 'claims.sub'
1081+
extra:
1082+
- key: 'example.com/tenant'
1083+
valueExpression: 'claims.tenant'
1084+
userValidationRules:
1085+
- expression: "!user.username.startsWith('system:')" # the expression will evaluate to true, so validation will succeed.
1086+
message: 'username cannot used reserved system: prefix'
1087+
```
1088+
10271089
-->
10281090
```yaml
10291091
apiVersion: apiserver.config.k8s.io/v1beta1
@@ -1085,9 +1147,33 @@ jwt:
10851147
{{% tab name="Fails user validation" %}}
10861148

10871149
<!--
1088-
# this will prefix the username with "system:" and will fail user validation.
1089-
# the username will be system:foo and expression will evaluate to false, so validation will fail.
1150+
```yaml
1151+
apiVersion: apiserver.config.k8s.io/v1beta1
1152+
kind: AuthenticationConfiguration
1153+
jwt:
1154+
- issuer:
1155+
url: https://example.com
1156+
audiences:
1157+
- my-app
1158+
claimValidationRules:
1159+
- expression: 'claims.hd == "example.com"'
1160+
message: the hd claim must be set to example.com
1161+
claimMappings:
1162+
username:
1163+
expression: '"system:" + claims.username' # this will prefix the username with "system:" and will fail user validation.
1164+
groups:
1165+
expression: 'claims.roles.split(",")'
1166+
uid:
1167+
expression: 'claims.sub'
1168+
extra:
1169+
- key: 'example.com/tenant'
1170+
valueExpression: 'claims.tenant'
1171+
userValidationRules:
1172+
- expression: "!user.username.startsWith('system:')" # the username will be system:foo and expression will evaluate to false, so validation will fail.
1173+
message: 'username cannot used reserved system: prefix'
1174+
```
10901175
-->
1176+
10911177
```yaml
10921178
apiVersion: apiserver.config.k8s.io/v1beta1
10931179
kind: AuthenticationConfiguration

0 commit comments

Comments
 (0)