Skip to content

Commit a958552

Browse files
authored
Merge pull request #38831 from windsonsea/autheny
[zh] sync /access-authn-authz/authentication.md
2 parents c2c438d + e01dadd commit a958552

File tree

1 file changed

+194
-0
lines changed

1 file changed

+194
-0
lines changed

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

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,200 @@ The following `ExecCredential` manifest describes a cluster information sample.
19871987
{{% /tab %}}
19881988
{{< /tabs >}}
19891989

1990+
<!--
1991+
## API access to authentication information for a client {#self-subject-review}
1992+
-->
1993+
## 为客户端提供的对身份验证信息的 API 访问 {#self-subject-review}
1994+
1995+
{{< feature-state for_k8s_version="v1.26" state="alpha" >}}
1996+
1997+
<!--
1998+
If your cluster has the API enabled, you can use the `SelfSubjectReview` API to find out how your Kubernetes cluster maps your authentication information to identify you as a client. This works whether you are authenticating as a user (typically representing a real person) or as a ServiceAccount.
1999+
2000+
`SelfSubjectReview` objects do not have any configurable fields. On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user.
2001+
2002+
Request example (the body would be a `SelfSubjectReview`):
2003+
-->
2004+
如果集群启用了此 API,你可以使用 `SelfSubjectReview` API 来了解 Kubernetes
2005+
集群如何映射你的身份验证信息从而将你识别为某客户端。无论你是作为用户(通常代表一个真的人)还是作为
2006+
ServiceAccount 进行身份验证,这一 API 都可以使用。
2007+
2008+
`SelfSubjectReview` 对象没有任何可配置的字段。
2009+
Kubernetes API 服务器收到请求后,将使用用户属性填充 status 字段并将其返回给用户。
2010+
2011+
请求示例(主体将是 `SelfSubjectReview`):
2012+
2013+
```
2014+
POST /apis/authentication.k8s.io/v1alpha1/selfsubjectreviews
2015+
```
2016+
2017+
```json
2018+
{
2019+
"apiVersion": "authentication.k8s.io/v1alpha1",
2020+
"kind": "SelfSubjectReview"
2021+
}
2022+
```
2023+
2024+
<!--
2025+
Response example:
2026+
-->
2027+
响应示例:
2028+
2029+
```json
2030+
{
2031+
"apiVersion": "authentication.k8s.io/v1alpha1",
2032+
"kind": "SelfSubjectReview",
2033+
"status": {
2034+
"userInfo": {
2035+
"name": "jane.doe",
2036+
"uid": "b6c7cfd4-f166-11ec-8ea0-0242ac120002",
2037+
"groups": [
2038+
"viewers",
2039+
"editors",
2040+
"system:authenticated"
2041+
],
2042+
"extra": {
2043+
"provider_id": ["token.company.example"]
2044+
}
2045+
}
2046+
}
2047+
}
2048+
```
2049+
2050+
<!--
2051+
For convenience, the `kubectl alpha auth whoami` command is present. Executing this command will produce the following output (yet different user attributes will be shown):
2052+
2053+
* Simple output example
2054+
-->
2055+
为了方便,Kubernetes 提供了 `kubectl alpha auth whoami` 命令。
2056+
执行此命令将产生以下输出(但将显示不同的用户属性):
2057+
2058+
* 简单的输出示例
2059+
2060+
```
2061+
ATTRIBUTE VALUE
2062+
Username jane.doe
2063+
Groups [system:authenticated]
2064+
```
2065+
2066+
<!--
2067+
* Complex example including extra attributes
2068+
-->
2069+
* 包括额外属性的复杂示例
2070+
2071+
```
2072+
ATTRIBUTE VALUE
2073+
Username jane.doe
2074+
UID b79dbf30-0c6a-11ed-861d-0242ac120002
2075+
Groups [students teachers system:authenticated]
2076+
Extra: skills [reading learning]
2077+
Extra: subjects [math sports]
2078+
```
2079+
2080+
<!--
2081+
By providing the output flag, it is also possible to print the JSON or YAML representation of the result:
2082+
-->
2083+
通过提供 output 标志,也可以打印结果的 JSON 或 YAML 表现形式:
2084+
2085+
{{< tabs name="self_subject_attributes_review_Example_1" >}}
2086+
{{% tab name="JSON" %}}
2087+
```json
2088+
{
2089+
"apiVersion": "authentication.k8s.io/v1alpha1",
2090+
"kind": "SelfSubjectReview",
2091+
"status": {
2092+
"userInfo": {
2093+
"username": "jane.doe",
2094+
"uid": "b79dbf30-0c6a-11ed-861d-0242ac120002",
2095+
"groups": [
2096+
"students",
2097+
"teachers",
2098+
"system:authenticated"
2099+
],
2100+
"extra": {
2101+
"skills": [
2102+
"reading",
2103+
"learning"
2104+
],
2105+
"subjects": [
2106+
"math",
2107+
"sports"
2108+
]
2109+
}
2110+
}
2111+
}
2112+
}
2113+
```
2114+
{{% /tab %}}
2115+
2116+
{{% tab name="YAML" %}}
2117+
```yaml
2118+
apiVersion: authentication.k8s.io/v1alpha1
2119+
kind: SelfSubjectReview
2120+
status:
2121+
userInfo:
2122+
username: jane.doe
2123+
uid: b79dbf30-0c6a-11ed-861d-0242ac120002
2124+
groups:
2125+
- students
2126+
- teachers
2127+
- system:authenticated
2128+
extra:
2129+
skills:
2130+
- reading
2131+
- learning
2132+
subjects:
2133+
- math
2134+
- sports
2135+
```
2136+
{{% /tab %}}
2137+
{{< /tabs >}}
2138+
2139+
<!--
2140+
This feature is extremely useful when a complicated authentication flow is used in a Kubernetes cluster,
2141+
for example, if you use [webhook token authentication](/docs/reference/access-authn-authz/authentication/#webhook-token-authentication) or [authenticating proxy](/docs/reference/access-authn-authz/authentication/#authenticating-proxy).
2142+
-->
2143+
在 Kubernetes 集群中使用复杂的身份验证流程时,例如如果你使用
2144+
[Webhook 令牌身份验证](/zh-cn/docs/reference/access-authn-authz/authentication/#webhook-token-authentication)或[身份验证代理](/zh-cn/docs/reference/access-authn-authz/authentication/#authenticating-proxy)时,
2145+
此特性极其有用。
2146+
2147+
{{< note >}}
2148+
<!--
2149+
The Kubernetes API server fills the `userInfo` after all authentication mechanisms are applied,
2150+
including [impersonation](/docs/reference/access-authn-authz/authentication/#user-impersonation).
2151+
If you, or an authentication proxy, make a SelfSubjectReview using impersonation,
2152+
you see the user details and properties for the user that was impersonated.
2153+
-->
2154+
Kubernetes API 服务器在所有身份验证机制
2155+
(包括[伪装](/zh-cn/docs/reference/access-authn-authz/authentication/#user-impersonation)),
2156+
被应用后填充 `userInfo`,
2157+
如果你或某个身份验证代理使用伪装进行 SelfSubjectReview,你会看到被伪装用户的用户详情和属性。
2158+
{{< /note >}}
2159+
2160+
<!--
2161+
By default, all authenticated users can create `SelfSubjectReview` objects when the `APISelfSubjectReview` feature is enabled. It is allowed by the `system:basic-user` cluster role.
2162+
-->
2163+
默认情况下,所有经过身份验证的用户都可以在 `APISelfSubjectReview` 特性被启用时创建 `SelfSubjectReview` 对象。
2164+
这是 `system:basic-user` 集群角色允许的操作。
2165+
2166+
{{< note >}}
2167+
<!--
2168+
You can only make `SelfSubjectReview` requests if:
2169+
* the `APISelfSubjectReview`
2170+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
2171+
is enabled for your cluster
2172+
* the API server for your cluster has the `authentication.k8s.io/v1alpha1`
2173+
{{< glossary_tooltip term_id="api-group" text="API group" >}}
2174+
enabled.
2175+
-->
2176+
你只能在以下情况下进行 `SelfSubjectReview` 请求:
2177+
2178+
* 集群启用了 `APISelfSubjectReview`
2179+
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
2180+
* 集群的 API 服务器已启用 `authentication.k8s.io/v1alpha1`
2181+
{{< glossary_tooltip term_id="api-group" text="API 组" >}}。。
2182+
{{< /note >}}
2183+
19902184
## {{% heading "whatsnext" %}}
19912185

19922186
<!--

0 commit comments

Comments
 (0)