@@ -482,34 +482,6 @@ is included in a request.
482
482
` id_token` (而非 `access_token`)作为持有者令牌。
483
483
关于如何在请求中设置令牌,可参见[前文](#putting-a-bearer-token-in-a-request)。
484
484
485
- <!--
486
- sequenceDiagram
487
- participant user as User
488
- participant idp as Identity Provider
489
- participant kube as kubectl
490
- participant api as API Server
491
-
492
- user ->> idp : 1. Log in to IdP
493
- activate idp
494
- idp -->> user : 2. Provide access_token,<br>id_token, and refresh_token
495
- deactivate idp
496
- activate user
497
- user ->> kube : 3. Call kubectl<br>with --token being the id_token<br>OR add tokens to .kube/config
498
- deactivate user
499
- activate kube
500
- kube ->> api : 4. Authorization: Bearer...
501
- deactivate kube
502
- activate api
503
- api ->> api : 5. Is JWT signature valid?
504
- api ->> api : 6. Has the JWT expired? (iat+exp)
505
- api ->> api : 7. User authorized?
506
- api -->> kube : 8. Authorized: Perform<br>action and return result
507
- deactivate api
508
- activate kube
509
- kube --x user : 9. Return result
510
- deactivate kube
511
- -->
512
-
513
485
{{< mermaid >}}
514
486
sequenceDiagram
515
487
participant user as 用户
@@ -560,7 +532,7 @@ sequenceDiagram
560
532
5. API 服务器将确保 JWT 的签名是有效的
561
533
6. 检查确认 `id_token` 尚未过期
562
534
563
- 如果使用 `AuthenticationConfiguration` 配置了 CEL 表达式,则执行声明和 /或用户验证。
535
+ 如果使用 `AuthenticationConfiguration` 配置了 CEL 表达式,则执行申领和 /或用户验证。
564
536
565
537
7. 确认用户有权限执行操作
566
538
8. 鉴权成功之后,API 服务器向 `kubectl` 返回响应
@@ -616,7 +588,6 @@ To enable the plugin, configure the following flags on the API server:
616
588
| `--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 |
617
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 |
618
590
-->
619
-
620
591
| 参数 | 描述 | 示例 | 必需? |
621
592
| --------- | ----------- | ------- | ------- |
622
593
| `--oidc-issuer-url` | 允许 API 服务器发现公开的签名密钥的服务的 URL。只接受模式为 `https://` 的 URL。此值通常设置为服务的发现 URL,已更改为空路径。 | 如果发行人的 OIDC 发现 URL 是 `https://accounts.google.com/.well-known/openid-configuration`,则此值应为 `https://accounts.provider.example` | 是 |
@@ -647,7 +618,7 @@ JWT Authenticator 是一个使用 JWT 兼容令牌对 Kubernetes 用户进行身
647
618
认证组件将尝试解析原始 ID 令牌,验证它是否是由所配置的颁发者签名。
648
619
用于验证签名的公钥是使用 OIDC 发现从发行者的公共端点发现的。
649
620
650
- 最小有效 JWT 负载必须包含以下声明 :
621
+ 最小有效 JWT 负载必须包含以下申领 :
651
622
652
623
<!--
653
624
` ` ` json
@@ -662,9 +633,9 @@ JWT Authenticator 是一个使用 JWT 兼容令牌对 Kubernetes 用户进行身
662
633
` ` ` json
663
634
{
664
635
"iss": "https://example.com", // 必须与 issuer.url 匹配
665
- "aud": ["my-app"], // issuer.audiences 中至少一项必须与所提供的 JWT 中的 "aud" 声明相匹配 。
636
+ "aud": ["my-app"], // issuer.audiences 中至少一项必须与所提供的 JWT 中的 "aud" 申领相匹配 。
666
637
"exp": 1234567890, // 令牌过期时间为 UNIX 时间(自 1970 年 1 月 1 日 UTC 以来经过的秒数)
667
- "<username-claim>": "user" // 这是在 claimMappings.username.claim 或 claimMappings.username.expression 中配置的用户名声明
638
+ "<username-claim>": "user" // 这是在 claimMappings.username.claim 或 claimMappings.username.expression 中配置的用户名申领
668
639
}
669
640
` ` `
670
641
@@ -678,7 +649,7 @@ to monitor the last time the configuration was reloaded by the API server.
678
649
-->
679
650
配置文件方法允许你配置多个 JWT 认证组件,每个身份认证组件都有唯一的 `issuer.url` 和 `issuer.discoveryURL`。
680
651
配置文件甚至允许你指定 [CEL](/zh-cn/docs/reference/using-api/cel/)
681
- 表达式以将声明映射到用户属性,并验证声明和用户信息 。
652
+ 表达式以将申领映射到用户属性,并验证申领和用户信息 。
682
653
当配置文件修改时,API 服务器还会自动重新加载认证组件。
683
654
你可以使用 `apiserver_authentication_config_controller_automatic_reload_last_timestamp_seconds`
684
655
指标来监控 API 服务器上次重新加载配置的时间。
@@ -716,7 +687,7 @@ If you want to switch to using structured authentication configuration, you have
716
687
command line arguments, and use the configuration file instead.
717
688
-->
718
689
你不能同时指定 `--authentication-config` 和 `--oidc-*` 命令行参数,
719
- 否则API服务器会报告错误 ,然后立即退出。
690
+ 否则 API 服务器会报告错误 ,然后立即退出。
720
691
如果你想切换到使用结构化身份认证配置,则必须删除 `--oidc-*` 命令行参数,并改用配置文件。
721
692
{{< /note >}}
722
693
850
821
# 系统会使用所给的配置值,因此如果需要,“/.well-known/openid-configuration” 必须包含在 discoveryURL 中。
851
822
#
852
823
# 取回的发现信息中的 “issuer” 字段必须与 AuthenticationConfiguration 中的
853
- # “issuer.url” 字段匹配,并被用于验证所呈现的 JWT 中的 “iss” 声明 。
824
+ # “issuer.url” 字段匹配,并被用于验证所呈现的 JWT 中的 “iss” 申领 。
854
825
# 这适用于众所周知的端点和 jwks 端点托管在与颁发者不同的位置(例如集群本地)的场景。
855
826
# discoveryURL 必须与 url 不同(如果指定),并且在所有认证组件中必须是唯一的。
856
827
discoveryURL: https://discovery.example.com/.well-known/openid-configuration
@@ -859,18 +830,18 @@ jwt:
859
830
# 与 --oidc-ca-file 标志引用的文件内容的值相同。
860
831
certificateAuthority: <PEM encoded CA certificates>
861
832
# audiences 是 JWT 必须发布给的一组可接受的受众。
862
- # 至少其中一项必须与所提供的 JWT 中的 “aud” 声明相匹配 。
833
+ # 至少其中一项必须与所提供的 JWT 中的 “aud” 申领相匹配 。
863
834
audiences:
864
835
- my-app # 与 --oidc-client-id 一致。
865
836
- my-other-app
866
837
# 当指定多个受众时,需要将此字段设置为 “MatchAny”。
867
838
audienceMatchPolicy: MatchAny
868
- # 用于验证令牌声明以对用户进行身份认证的规则 。
839
+ # 用于验证令牌申领以对用户进行身份认证的规则 。
869
840
claimValidationRules:
870
841
# 与 --oidc-required-claim key=value 一致
871
842
- claim: hd
872
843
requiredValue: example.com
873
- # 你可以使用表达式来验证声明 ,而不是仅仅靠 claim 和 requiredValue 来执行检查。
844
+ # 你可以使用表达式来验证申领 ,而不是仅仅靠 claim 和 requiredValue 来执行检查。
874
845
# expression 是一个计算结果为布尔值的 CEL 表达式。
875
846
# 所有表达式的计算结果必须为 true 才能使验证成功。
876
847
- expression: 'claims.hd == "example.com"'
@@ -893,10 +864,10 @@ jwt:
893
864
#
894
865
# 1. 如果 username.expression 使用 “claims.email”,则必须在 username.expression
895
866
# 或 extra[*].valueExpression 或 ClaimValidationRules[*].expression 中使用 “claims.email_verified”。
896
- # 与 username.claim 设置为 “email” 时自动应用的验证相匹配的示例声明验证规则表达式是
867
+ # 与 username.claim 设置为 “email” 时自动应用的验证相匹配的示例申领验证规则表达式是
897
868
# “claims.?email_verified.orValue(true) == true”。
898
869
# 通过显式地将该值与 true 进行比较,可以让类型检查器识别出结果是布尔值,
899
- # 并确保在运行时能够识别出任何非布尔类型的 email_verified 声明 。
870
+ # 并确保在运行时能够识别出任何非布尔类型的 email_verified 申领 。
900
871
# 2. 如果根据 username.expression 断言的用户名是空字符串,则身份认证请求将失败。
901
872
expression: 'claims.username + ":external-user"'
902
873
# groups 代表 groups 属性的一个选项。
@@ -946,11 +917,11 @@ jwt:
946
917
CEL expressions have access to the contents of the token payload, organized into `claims` CEL variable.
947
918
` claims` is a map of claim names (as strings) to claim values (of any type).
948
919
-->
949
- * 声明验证规则表达式
920
+ * 申领验证规则表达式
950
921
951
- ` jwt.claimValidationRules[i].expression` 表示将由 CEL 计算的表达式。
952
- CEL 表达式可以访问令牌有效负载的内容,这些内容被组织成 `claims` CEL 变量。
953
- ` claims` 是声明名称 (作为字符串)到声明值 (任何类型)的映射。
922
+ ` jwt.claimValidationRules[i].expression` 表示将由 CEL 计算的表达式。
923
+ CEL 表达式可以访问令牌有效负载的内容,这些内容被组织成 `claims` CEL 变量。
924
+ ` claims` 是申领名称 (作为字符串)到申领值 (任何类型)的映射。
954
925
955
926
<!--
956
927
* User validation rule expression
@@ -962,10 +933,10 @@ jwt:
962
933
-->
963
934
* 用户验证规则表达式
964
935
965
- ` jwt.userValidationRules[i].expression` 表示将由 CEL 计算的表达式。
936
+ ` jwt.userValidationRules[i].expression` 表示将由 CEL 计算的表达式。
966
937
CEL 表达式可以访问 `userInfo` 的内容,并组织成 `user` CEL 变量。
967
938
有关 `user` 的结构,请参阅
968
- [UserInfo](/zh-cn/ docs/reference/generated/kubernetes-api/v{{< skew currentVersion >}}/#userinfo-v1-authentication-k8s-io) API 文档。
939
+ [UserInfo](/docs/reference/generated/kubernetes-api/v{{< skew currentVersion >}}/#userinfo-v1-authentication-k8s-io) API 文档。
969
940
970
941
<!--
971
942
* Claim mapping expression
@@ -975,24 +946,25 @@ jwt:
975
946
CEL expressions have access to the contents of the token payload, organized into `claims` CEL variable.
976
947
` claims` is a map of claim names (as strings) to claim values (of any type).
977
948
-->
978
- * 声明映射表达式
949
+ * 申领映射表达式
979
950
980
951
` jwt.claimMappings.username.expression` 、`jwt.claimMappings.groups.expression`、
981
952
` jwt.claimMappings.uid.expression` ` jwt.claimMappings.extra[i].valueExpression` 表示将由 CEL 计算的表达式。
982
953
CEL 表达式可以访问令牌有效负载的内容,这些内容被组织成 `claims` CEL 变量。
983
- ` claims` 是声明名称 (作为字符串)到声明值 (任何类型)的映射。
954
+ ` claims` 是申领名称 (作为字符串)到申领值 (任何类型)的映射。
984
955
985
956
<!--
986
957
To learn more, see the [Documentation on CEL](/docs/reference/using-api/cel/)
987
958
988
959
Here are examples of the `AuthenticationConfiguration` with different token payloads.
989
960
-->
961
+
990
962
要了解更多信息,请参阅 [CEL 文档](/zh-cn/docs/reference/using-api/cel/)。
991
963
992
964
以下是具有不同令牌有效负载的 “AuthenticationConfiguration” 示例。
993
965
994
966
{{< tabs name="example_configuration" >}}
995
- {{% tab name="Valid token " %}}
967
+ {{% tab name="合法的令牌 " %}}
996
968
<!--
997
969
` ` ` yaml
998
970
apiVersion: apiserver.config.k8s.io/v1beta1
@@ -1085,7 +1057,7 @@ jwt:
1085
1057
` ` `
1086
1058
1087
1059
{{% /tab %}}
1088
- {{% tab name="Fails claim validation " %}}
1060
+ {{% tab name="申领校验失败 " %}}
1089
1061
<!--
1090
1062
` ` ` yaml
1091
1063
apiVersion: apiserver.config.k8s.io/v1beta1
@@ -1112,8 +1084,8 @@ jwt:
1112
1084
- expression: "!user.username.startsWith('system:')" # the expression will evaluate to true, so validation will succeed.
1113
1085
message: 'username cannot used reserved system: prefix'
1114
1086
` ` `
1115
-
1116
1087
-->
1088
+
1117
1089
` ` ` yaml
1118
1090
apiVersion: apiserver.config.k8s.io/v1beta1
1119
1091
kind: AuthenticationConfiguration
@@ -1123,7 +1095,7 @@ jwt:
1123
1095
audiences:
1124
1096
- my-app
1125
1097
claimValidationRules:
1126
- - expression: 'claims.hd == "example.com"' # 下面的令牌没有此声明 ,因此验证将失败。
1098
+ - expression: 'claims.hd == "example.com"' # 下面的令牌没有此申领 ,因此验证将失败。
1127
1099
message: the hd claim must be set to example.com
1128
1100
claimMappings:
1129
1101
username:
@@ -1169,9 +1141,9 @@ jwt:
1169
1141
` hd` claim is not set to `example.com`. The API server will return `401 Unauthorized` error.
1170
1142
-->
1171
1143
具有上述 `AuthenticationConfiguration` 的令牌将无法进行身份认证,
1172
- 因为 `hd` 声明未设置为 `example.com`。API 服务器将返回 `401 Unauthorized` 错误。
1144
+ 因为 `hd` 申领未设置为 `example.com`。API 服务器将返回 `401 Unauthorized` 错误。
1173
1145
{{% /tab %}}
1174
- {{% tab name="Fails user validation " %}}
1146
+ {{% tab name="用户校验失败 " %}}
1175
1147
1176
1148
<!--
1177
1149
` ` ` yaml
@@ -1226,6 +1198,7 @@ jwt:
1226
1198
- expression: "!user.username.startsWith('system:')" # 用户名将为 system:foo 并且表达式将计算为 false,因此验证将失败。
1227
1199
message: 'username cannot used reserved system: prefix'
1228
1200
` ` `
1201
+
1229
1202
` ` ` bash
1230
1203
TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6ImY3dF9tOEROWmFTQk1oWGw5QXZTWGhBUC04Y0JmZ0JVbFVpTG5oQkgxdXMiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNzAzMjMyOTQ5LCJoZCI6ImV4YW1wbGUuY29tIiwiaWF0IjoxNzAxMTEzMTAxLCJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tIiwianRpIjoiYjViMDY1MjM3MmNkMjBlMzQ1YjZmZGZmY2RjMjE4MWY0YWZkNmYyNTlhYWI0YjdlMzU4ODEyMzdkMjkyMjBiYyIsIm5iZiI6MTcwMTExMzEwMSwicm9sZXMiOiJ1c2VyLGFkbWluIiwic3ViIjoiYXV0aCIsInRlbmFudCI6IjcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0YSIsInVzZXJuYW1lIjoiZm9vIn0.FgPJBYLobo9jnbHreooBlvpgEcSPWnKfX6dc0IvdlRB-F0dCcgy91oCJeK_aBk-8zH5AKUXoFTlInfLCkPivMOJqMECA1YTrMUwt_IVqwb116AqihfByUYIIqzMjvUbthtbpIeHQm2fF0HbrUqa_Q0uaYwgy8mD807h7sBcUMjNd215ff_nFIHss-9zegH8GI1d9fiBf-g6zjkR1j987EP748khpQh9IxPjMJbSgG_uH5x80YFuqgEWwq-aYJPQxXX6FatP96a2EAn7wfPpGlPRt0HcBOvq5pCnudgCgfVgiOJiLr_7robQu4T1bis0W75VPEvwWtgFcLnvcQx0JWg
1231
1204
` ` `
@@ -1254,7 +1227,7 @@ jwt:
1254
1227
<!--
1255
1228
The token with the above `AuthenticationConfiguration` will produce the following `UserInfo` object :
1256
1229
-->
1257
- 具有上述 “AuthenticationConfiguration” 的令牌将生成以下 “ UserInfo” 对象:
1230
+ 具有上述 “AuthenticationConfiguration” 的令牌将生成以下 ` UserInfo` 对象:
1258
1231
1259
1232
` ` ` json
1260
1233
{
@@ -1286,7 +1259,7 @@ jwt:
1286
1259
-->
1287
1260
# ##### 局限性
1288
1261
1289
- 1. 分布式声明无法通过 [CEL](/zh-cn/docs/reference/using-api/cel/) 表达式工作。
1262
+ 1. 分布式申领无法通过 [CEL](/zh-cn/docs/reference/using-api/cel/) 表达式工作。
1290
1263
2. 不支持调用 `issuer.url` 和 `issuer.discoveryURL` 的出口选择器配置。
1291
1264
1292
1265
<!--
@@ -1460,7 +1433,7 @@ file format. Within the file, `clusters` refers to the remote service and
1460
1433
`users` refers to the API server webhook. An example would be :
1461
1434
-->
1462
1435
配置文件使用 [kubeconfig](/zh-cn/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
1463
- 文件的格式。文件中 ,`clusters` 指代远程服务,`users` 指代远程 API 服务
1436
+ 文件的格式。在此文件中 ,`clusters` 指代远程服务,`users` 指代远程 API 服务
1464
1437
Webhook。下面是一个例子:
1465
1438
1466
1439
<!--
@@ -1543,6 +1516,7 @@ and **must** respond with a `TokenReview` object of the same version as the requ
1543
1516
1544
1517
{{< tabs name="TokenReview_request" >}}
1545
1518
{{% tab name="authentication.k8s.io/v1" %}}
1519
+
1546
1520
{{< note >}}
1547
1521
<!--
1548
1522
The Kubernetes API server defaults to sending `authentication.k8s.io/v1beta1` token reviews for backwards compatibility.
@@ -1552,6 +1526,7 @@ Kubernetes API 服务器默认发送 `authentication.k8s.io/v1beta1` 令牌以
1552
1526
要选择接收 `authentication.k8s.io/v1` 令牌认证,API 服务器必须带着参数
1553
1527
` --authentication-token-webhook-version=v1` 启动。
1554
1528
{{< /note >}}
1529
+
1555
1530
<!--
1556
1531
` ` ` yaml
1557
1532
{
@@ -1685,15 +1660,15 @@ A successful validation of the bearer token would return:
1685
1660
" status " : {
1686
1661
" authenticated " : true,
1687
1662
" user " : {
1688
- # 必要
1663
+ # 必需
1689
1664
1690
1665
# 可选
1691
1666
" uid " : " 42" ,
1692
1667
# 可选的组成员身份
1693
1668
" groups " : ["developers", "qa"],
1694
1669
# 认证者提供的可选附加信息。
1695
1670
# 此字段不可包含机密数据,因为这类数据可能被记录在日志或 API 对象中,
1696
- # 并且可能传递给 admission webhook 。
1671
+ # 并且可能传递给准入 Webhook 。
1697
1672
" extra " : {
1698
1673
" extrafield1 " : [
1699
1674
" extravalue1" ,
@@ -1749,15 +1724,15 @@ A successful validation of the bearer token would return:
1749
1724
" status " : {
1750
1725
" authenticated " : true,
1751
1726
" user " : {
1752
- # 必要
1727
+ # 必需
1753
1728
1754
1729
# 可选
1755
1730
" uid " : " 42" ,
1756
1731
# 可选的组成员身份
1757
1732
" groups " : ["developers", "qa"],
1758
1733
# 认证者提供的可选附加信息。
1759
1734
# 此字段不可包含机密数据,因为这类数据可能被记录在日志或 API 对象中,
1760
- # 并且可能传递给 admission webhook 。
1735
+ # 并且可能传递给准入 Webhook 。
1761
1736
" extra " : {
1762
1737
" extrafield1 " : [
1763
1738
" extravalue1" ,
@@ -2775,7 +2750,7 @@ and required in `client.authentication.k8s.io/v1`.
2775
2750
插件的 `stdin` 需求(即,为了能够让插件成功运行,是否 `stdin` 是可选的、
2776
2751
必须提供的或者从不会被使用的)是通过
2777
2752
[kubeconfig](/zh-cn/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
2778
- 中的 `user.exec.interactiveMode` 来声明的 (参见下面的表格了解合法值)。
2753
+ 中的 `user.exec.interactiveMode` 来申领的 (参见下面的表格了解合法值)。
2779
2754
字段 `user.exec.interactiveMode` 在 `client.authentication.k8s.io/v1beta1`
2780
2755
中是可选的,在 `client.authentication.k8s.io/v1` 中是必需的。
2781
2756
0 commit comments