Skip to content

Commit fb4c28a

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

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

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

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,34 @@ is included in a request.
482482
`id_token`(而非 `access_token`)作为持有者令牌。
483483
关于如何在请求中设置令牌,可参见[前文](#putting-a-bearer-token-in-a-request)。
484484

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+
485513
{{< mermaid >}}
486514
sequenceDiagram
487515
participant user as 用户
@@ -722,7 +750,7 @@ jwt:
722750
# PEM encoded CA certificates used to validate the connection when fetching
723751
# discovery information. If not set, the system verifier will be used.
724752
# Same value as the content of the file referenced by the --oidc-ca-file flag.
725-
certificateAuthority: <PEM encoded CA certificates>
753+
certificateAuthority: <PEM encoded CA certificates>
726754
# audiences is the set of acceptable audiences the JWT must be issued to.
727755
# At least one of the entries must match the "aud" claim in presented JWTs.
728756
audiences:
@@ -936,8 +964,8 @@ jwt:
936964

937965
`jwt.userValidationRules[i].expression` 表示将由 CEL 计算的表达式。
938966
CEL 表达式可以访问 `userInfo` 的内容,并组织成 `user` CEL 变量。
939-
有关 `user` 的架构,请参阅
940-
[UserInfo](/zh-cn/docs/reference/ generated/kubernetes-api/v{{< skew currentVersion >}}/#userinfo-v1-authentication-k8s-io) API 文档。
967+
有关 `user` 的结构,请参阅
968+
[UserInfo](/zh-cn/docs/reference/generated/kubernetes-api/v{{< skew currentVersion >}}/#userinfo-v1-authentication-k8s-io) API 文档。
941969

942970
<!--
943971
* Claim mapping expression
@@ -963,7 +991,6 @@ jwt:
963991

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

966-
967994
{{< tabs name="example_configuration" >}}
968995
{{% tab name="Valid token" %}}
969996
<!--
@@ -1247,7 +1274,7 @@ jwt:
12471274
which will fail user validation because the username starts with `system:`.
12481275
The API server will return `401 Unauthorized` error.
12491276
-->
1250-
这将导致用户验证失败,因为用户名以 `system:` 开头。 API 服务器将返回 `401 Unauthorized` 错误。
1277+
这将导致用户验证失败,因为用户名以 `system:` 开头。API 服务器将返回 `401 Unauthorized` 错误。
12511278
{{% /tab %}}
12521279
{{< /tabs >}}
12531280

@@ -1264,20 +1291,12 @@ jwt:
12641291

12651292
<!--
12661293
Kubernetes does not provide an OpenID Connect Identity Provider.
1267-
You can use an existing public OpenID Connect Identity Provider (such as Google, or
1268-
[others](https://connect2id.com/products/nimbus-oauth-openid-connect-sdk/openid-connect-providers)).
1269-
Or, you can run your own Identity Provider, such as [dex](https://dexidp.io/),
1270-
[Keycloak](https://github.com/keycloak/keycloak),
1271-
CloudFoundry [UAA](https://github.com/cloudfoundry/uaa), or
1272-
Tremolo Security's [OpenUnison](https://openunison.github.io/).
1294+
You can use an existing public OpenID Connect Identity Provider or run your own Identity Provider
1295+
that supports the OpenID Connect protocol.
12731296
-->
12741297
Kubernetes 并未提供 OpenID Connect 的身份服务。
1275-
你可以使用现有的公共的 OpenID Connect 身份服务
1276-
(例如 Google 或者[其他服务](https://connect2id.com/products/nimbus-oauth-openid-connect-sdk/openid-connect-providers))。
1277-
或者,你也可以选择自己运行一个身份服务,例如 [dex](https://dexidp.io/)、
1278-
[Keycloak](https://github.com/keycloak/keycloak)、
1279-
CloudFoundry [UAA](https://github.com/cloudfoundry/uaa) 或者
1280-
Tremolo Security 的 [OpenUnison](https://openunison.github.io/)。
1298+
你可以使用现有的公共的 OpenID Connect 身份服务或者运行你自己的
1299+
OpenID Connect 身份服务。
12811300

12821301
<!--
12831302
For an identity provider to work with Kubernetes it must:
@@ -1306,33 +1325,18 @@ For an identity provider to work with Kubernetes it must:
13061325

13071326
<!--
13081327
A note about requirement #3 above, requiring a CA signed certificate. If you deploy your own
1309-
identity provider (as opposed to one of the cloud providers like Google or Microsoft) you MUST
1310-
have your identity provider's web server certificate signed by a certificate with the `CA` flag
1311-
set to `TRUE`, even if it is self signed. This is due to GoLang's TLS client implementation
1312-
being very strict to the standards around certificate validation. If you don't have a CA handy,
1313-
you can use the [gencert script](https://github.com/dexidp/dex/blob/master/examples/k8s/gencert.sh)
1314-
from the Dex team to create a simple CA and a signed certificate and key pair. Or you can use
1315-
[this similar script](https://raw.githubusercontent.com/TremoloSecurity/openunison-qs-kubernetes/master/src/main/bash/makessl.sh)
1316-
that generates SHA256 certs with a longer life and larger key size.
1328+
identity provider you MUST have your identity provider's web server certificate signed by a
1329+
certificate with the `CA` flag set to `TRUE`, even if it is self signed. This is due to GoLang's
1330+
TLS client implementation being very strict to the standards around certificate validation. If you
1331+
don't have a CA handy, you can create a simple CA and a signed certificate and key pair using
1332+
standard certificate generation tools.
13171333
-->
13181334
关于上述第三条需求,即要求具备 CA 签名的证书,有一些额外的注意事项。
1319-
如果你部署了自己的身份服务,而不是使用云厂商(如 Google 或 Microsoft)所提供的服务,
1320-
你必须对身份服务的 Web 服务器证书进行签名,签名所用证书的 `CA` 标志要设置为
1321-
`TRUE`,即使用的是自签名证书。这是因为 GoLang 的 TLS 客户端实现对证书验证标准方面有非常严格的要求。
1322-
如果你手头没有现成的 CA 证书,可以使用 Dex
1323-
团队所开发的[证书生成脚本](https://github.com/dexidp/dex/blob/master/examples/k8s/gencert.sh)
1324-
来创建一个简单的 CA 和被签了名的证书与密钥对。
1325-
或者你也可以使用[这个类似的脚本](https://raw.githubusercontent.com/TremoloSecurity/openunison-qs-kubernetes/master/src/main/bash/makessl.sh),
1326-
生成一个合法期更长、密钥尺寸更大的 SHA256 证书。
1327-
1328-
<!--
1329-
Refer to setup instructions for specific systems:
1330-
-->
1331-
参阅特定系统的安装指令:
1332-
1333-
- [UAA](https://docs.cloudfoundry.org/concepts/architecture/uaa.html)
1334-
- [Dex](https://dexidp.io/docs/kubernetes/)
1335-
- [OpenUnison](https://www.tremolosecurity.com/orchestra-k8s/)
1335+
如果你部署了自己的身份服务,你必须对身份服务的 Web 服务器证书进行签名,
1336+
签名所用证书的 `CA` 标志要设置为 `TRUE`,即使用的是自签名证书。
1337+
这是因为 GoLang 的 TLS 客户端实现对证书验证标准方面有非常严格的要求。
1338+
如果你手头没有现成的 CA 证书,可以使用标准证书生成工具来创建一个简单的
1339+
CA 和被签了名的证书与密钥对。
13361340

13371341
<!--
13381342
#### Using kubectl
@@ -1448,7 +1452,7 @@ Webhook 身份认证是一种用来验证持有者令牌的回调机制。
14481452
默认时长为 2 分钟。
14491453
* `--authentication-token-webhook-version` 决定是使用 `authentication.k8s.io/v1beta1` 还是
14501454
`authenticationk8s.io/v1` 版本的 `TokenReview` 对象从 Webhook 发送/接收信息。
1451-
默认为v1beta1
1455+
默认为 `v1beta1`
14521456

14531457
<!--
14541458
The configuration file uses the [kubeconfig](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
@@ -1535,7 +1539,7 @@ and **must** respond with a `TokenReview` object of the same version as the requ
15351539
要注意的是,Webhook API 对象和其他 Kubernetes API 对象一样,
15361540
也要受到同一[版本兼容规则](/zh-cn/docs/concepts/overview/kubernetes-api/)约束。
15371541
实现者应检查请求的 `apiVersion` 字段以确保正确的反序列化,
1538-
并且 **必须** 以与请求相同版本的 `TokenReview` 对象进行响应。
1542+
并且**必须**以与请求相同版本的 `TokenReview` 对象进行响应。
15391543

15401544
{{< tabs name="TokenReview_request" >}}
15411545
{{% tab name="authentication.k8s.io/v1" %}}
@@ -1573,7 +1577,7 @@ Kubernetes API 服务器默认发送 `authentication.k8s.io/v1beta1` 令牌以
15731577
"apiVersion": "authentication.k8s.io/v1",
15741578
"kind": "TokenReview",
15751579
"spec": {
1576-
# 发送到 API 服务器的不透明持有者令牌
1580+
# 发送到 API 服务器的不透明持有者令牌
15771581
"token": "014fbff9a07c...",
15781582
15791583
# 提供令牌的服务器的受众标识符的可选列表。
@@ -2115,7 +2119,7 @@ The following HTTP headers can be used to performing an impersonation request:
21152119
此字段可选;要求 "Impersonate-User" 被设置。为了能够以一致的形式保留,
21162120
`<附加名称>`部分必须是小写字符,
21172121
如果有任何字符不是[合法的 HTTP 头部标签字符](https://tools.ietf.org/html/rfc7230#section-3.2.6),
2118-
则必须是 utf8 字符,且转换为[百分号编码](https://tools.ietf.org/html/rfc3986#section-2.1)。
2122+
则必须是 UTF-8 字符,且转换为[百分号编码](https://tools.ietf.org/html/rfc3986#section-2.1)。
21192123
* `Impersonate-Uid`:一个唯一标识符,用来表示所伪装的用户。此头部可选。
21202124
如果设置,则要求 "Impersonate-User" 也存在。Kubernetes 对此字符串没有格式要求。
21212125

@@ -2519,7 +2523,7 @@ users:
25192523
- "arg1"
25202524
- "arg2"
25212525
2522-
# 当可执行文件不存在时显示给用户的文本。可选的
2526+
# 当可执行文件不存在时显示给用户的文本。可选字段
25232527
installHint: |
25242528
需要 example-client-go-exec-plugin 来在当前集群上执行身份认证。可以通过以下命令安装:
25252529
@@ -2662,7 +2666,7 @@ users:
26622666
- "arg1"
26632667
- "arg2"
26642668
2665-
# 当可执行文件不存在时显示给用户的文本。可选的
2669+
# 当可执行文件不存在时显示给用户的文本。可选字段
26662670
installHint: |
26672671
需要 example-client-go-exec-plugin 来在当前集群上执行身份认证。可以通过以下命令安装:
26682672
@@ -2702,7 +2706,6 @@ contexts:
27022706
user: my-user
27032707
current-context: my-cluster
27042708
```
2705-
27062709
{{% /tab %}}
27072710
{{< /tabs >}}
27082711

@@ -2953,6 +2956,7 @@ The following `ExecCredential` manifest describes a cluster information sample.
29532956
}
29542957
```
29552958
{{% /tab %}}
2959+
29562960
{{% tab name="client.authentication.k8s.io/v1beta1" %}}
29572961
```json
29582962
{

0 commit comments

Comments
 (0)