Skip to content

Commit b9f6408

Browse files
committed
[zh] Resync /access-authn-authz/authentication.md
1 parent 574d24c commit b9f6408

File tree

1 file changed

+27
-65
lines changed

1 file changed

+27
-65
lines changed

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

Lines changed: 27 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ talk to the API server. Accounts may be explicitly associated with pods using th
353353
{{< /note >}}
354354

355355
```yaml
356-
apiVersion: apps/v1
356+
apiVersion: apps/v1 # 此 apiVersion 从 Kubernetes 1.9 开始可用
357357
kind: Deployment
358358
metadata:
359359
name: nginx-deployment
@@ -375,106 +375,68 @@ Service account bearer tokens are perfectly valid to use outside the cluster and
375375
can be used to create identities for long standing jobs that wish to talk to the
376376
Kubernetes API. To manually create a service account, use the `kubectl create
377377
serviceaccount (NAME)` command. This creates a service account in the current
378-
namespace and an associated secret.
378+
namespace.
379379
-->
380380
在集群外部使用服务账号持有者令牌也是完全合法的,且可用来为长时间运行的、需要与 Kubernetes
381381
API 服务器通信的任务创建标识。要手动创建服务账号,可以使用
382382
`kubectl create serviceaccount <名称>` 命令。
383-
此命令会在当前的名字空间中生成一个服务账号和一个与之关联的 Secret
383+
此命令会在当前的名字空间中生成一个服务账号
384384

385385
```bash
386386
kubectl create serviceaccount jenkins
387387
```
388388

389-
```
390-
serviceaccount "jenkins" created
391-
```
392-
393-
<!--
394-
Check an associated secret:
395-
-->
396-
查验相关联的 Secret:
397-
398-
```bash
399-
kubectl get serviceaccounts jenkins -o yaml
400-
```
401-
402-
```yaml
403-
apiVersion: v1
404-
kind: ServiceAccount
405-
metadata:
406-
# ...
407-
secrets:
408-
- name: jenkins-token-1yvwg
389+
```none
390+
serviceaccount/jenkins created
409391
```
410392

411393
<!--
412-
The created secret holds the public CA of the API server and a signed JSON Web
413-
Token (JWT).
394+
Create an associated token:
414395
-->
415-
所创建的 Secret 中会保存 API 服务器的公开的 CA 证书和一个已签名的 JSON Web 令牌(JWT)。
396+
创建相关联的令牌:
416397

417398
```bash
418-
kubectl get secret jenkins-token-1yvwg -o yaml
399+
kubectl create token jenkins
419400
```
420401

421-
<!--
422-
```yaml
423-
apiVersion: v1
424-
data:
425-
ca.crt: (APISERVER'S CA BASE64 ENCODED)
426-
namespace: ZGVmYXVsdA==
427-
token: (BEARER TOKEN BASE64 ENCODED)
428-
kind: Secret
429-
metadata:
430-
# ...
431-
type: kubernetes.io/service-account-token
432-
```
433-
-->
434-
```yaml
435-
apiVersion: v1
436-
data:
437-
ca.crt: <Base64 编码的 API 服务器 CA>
438-
namespace: ZGVmYXVsdA==
439-
token: <Base64 编码的持有者令牌>
440-
kind: Secret
441-
metadata:
442-
# ...
443-
type: kubernetes.io/service-account-token
402+
```none
403+
eyJhbGciOiJSUzI1NiIsImtp...
444404
```
445405

446-
{{< note >}}
447406
<!--
448-
Values are base64 encoded because secrets are always base64 encoded.
407+
The created token is a signed JSON Web Token (JWT).
449408
-->
450-
字段值是按 Base64 编码的,这是因为 Secret 数据总是采用 Base64 编码来存储。
451-
{{< /note >}}
409+
所创建的令牌是一个已签名的 JWT 令牌。
452410

453411
<!--
454412
The signed JWT can be used as a bearer token to authenticate as the given service
455413
account. See [above](#putting-a-bearer-token-in-a-request) for how the token is included
456-
in a request. Normally these secrets are mounted into pods for in-cluster access to
414+
in a request. Normally these tokens are mounted into pods for in-cluster access to
457415
the API server, but can be used from outside the cluster as well.
458416
-->
459417
已签名的 JWT 可以用作持有者令牌,并将被认证为所给的服务账号。
460418
关于如何在请求中包含令牌,请参阅[前文](#putting-a-bearer-token-in-a-request)。
461-
通常,这些 Secret 数据会被挂载到 Pod 中以便集群内访问 API 服务器时使用,
419+
通常,这些令牌数据会被挂载到 Pod 中以便集群内访问 API 服务器时使用,
462420
不过也可以在集群外部使用。
463421

464422
<!--
465423
Service accounts authenticate with the username `system:serviceaccount:(NAMESPACE):(SERVICEACCOUNT)`,
466424
and are assigned to the groups `system:serviceaccounts` and `system:serviceaccounts:(NAMESPACE)`.
467-
468-
WARNING: Because service account tokens are stored in secrets, any user with
469-
read access to those secrets can authenticate as the service account. Be cautious
470-
when granting permissions to service accounts and read capabilities for secrets.
471425
-->
472426
服务账号被身份认证后,所确定的用户名为 `system:serviceaccount:<名字空间>:<服务账号>`,
473427
并被分配到用户组 `system:serviceaccounts` 和 `system:serviceaccounts:<名字空间>`。
474428

475-
警告:由于服务账号令牌保存在 Secret 对象中,任何能够读取这些 Secret
476-
的用户都可以被认证为对应的服务账号。在为用户授予访问服务账号的权限时,以及对 Secret
477-
的读权限时,要格外小心。
429+
{{< warning >}}
430+
<!--
431+
Because service account tokens can also be stored in Secret API objects, any user with
432+
write access to Secrets can request a token, and any user with read access to those
433+
Secrets can authenticate as the service account. Be cautious when granting permissions
434+
to service accounts and read or write capabilities for Secrets.
435+
-->
436+
由于服务账号令牌也可以保存在 Secret API 对象中,任何能够写入这些 Secret
437+
的用户都可以请求一个令牌,且任何能够读取这些 Secret 的用户都可以被认证为对应的服务账号。
438+
在为用户授予访问服务账号的权限以及对 Secret 的读取或写入权能时,要格外小心。
439+
{{< /warning >}}
478440

479441
<!--
480442
### OpenID Connect Tokens
@@ -488,11 +450,11 @@ email, signed by the server.
488450
-->
489451
### OpenID Connect(OIDC)令牌 {#openid-connect-tokens}
490452

491-
[OpenID Connect](https://openid.net/connect/) 是一种 OAuth2 认证方式,
453+
[OpenID Connect](https://openid.net/connect/) 是一种 OAuth2 认证方式,
492454
被某些 OAuth2 提供者支持,例如 Azure 活动目录、Salesforce 和 Google。
493455
协议对 OAuth2 的主要扩充体现在有一个附加字段会和访问令牌一起返回,
494456
这一字段称作 [ID Token(ID 令牌)](https://openid.net/specs/openid-connect-core-1_0.html#IDToken)。
495-
ID 令牌是一种由服务器签名的 JSON Web 令牌(JWT),其中包含一些可预知的字段,
457+
ID 令牌是一种由服务器签名的 JWT 令牌,其中包含一些可预知的字段,
496458
例如用户的邮箱地址,
497459

498460
<!--

0 commit comments

Comments
 (0)