@@ -188,6 +188,10 @@ Examples:
188
188
| ` lowPriorities.map(x, x.priority).max() < highPriorities.map(x, x.priority).min() ` | 验证两组优先级不重叠 |
189
189
| ` names.indexOf('should-be-first') == 1 ` | 如果是特定值,则使用列表中的第一个名称 |
190
190
191
+ <!--
192
+ See the [Kubernetes List Library](https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library#Lists)
193
+ godoc for more information.
194
+ -->
191
195
更多信息请查阅 Go 文档:
192
196
[ Kubernetes 列表库] ( https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library#Lists ) 。
193
197
{{< /table >}}
@@ -283,6 +287,85 @@ godoc for more information.
283
287
更多信息请查阅 Go 文档:
284
288
[ Kubernetes URL 库] ( https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library#URLs ) 。
285
289
290
+ <!--
291
+ ### Kubernetes authorizer library
292
+
293
+ For CEL expressions in the API where a variable of type `Authorizer` is available,
294
+ the authorizer may be used to perform authorization checks for the principal
295
+ (authenticated user) of the request.
296
+
297
+ API resource checks are performed as follows:
298
+ -->
299
+ ### Kubernetes 鉴权组件库
300
+
301
+ 在 API 中使用 CEL 表达式,可以使用类型为 ` Authorizer ` 的变量,
302
+ 这个鉴权组件可用于对请求的主体(已认证用户)执行鉴权检查。
303
+
304
+ API 资源检查的过程如下:
305
+
306
+ <!--
307
+ 1. Specify the group and resource to check: `Authorizer.group(string).resource(string) ResourceCheck`
308
+ 2. Optionally call any combination of the following builder functions to further narrow the authorization check.
309
+ Note that these functions return the receiver type and can be chained:
310
+ - `ResourceCheck.subresource(string) ResourceCheck`
311
+ - `ResourceCheck.namespace(string) ResourceCheck`
312
+ - `ResourceCheck.name(string) ResourceCheck`
313
+ 3. Call `ResourceCheck.check(verb string) Decision` to perform the authorization check.
314
+ 4. Call `allowed() bool` or `reason() string` to inspect the result of the authorization check.
315
+ -->
316
+ 1 . 指定要检查的组和资源:` Authorizer.group(string).resource(string) ResourceCheck `
317
+ 2 . 可以调用以下任意组合的构建器函数(Builder Function),以进一步缩小鉴权检查范围。
318
+ 注意这些函数将返回接收者的类型,并且可以串接起来:
319
+ - ` ResourceCheck.subresource(string) ResourceCheck `
320
+ - ` ResourceCheck.namespace(string) ResourceCheck `
321
+ - ` ResourceCheck.name(string) ResourceCheck `
322
+ 3 . 调用 ` ResourceCheck.check(verb string) Decision ` 来执行鉴权检查。
323
+ 4 . 调用 ` allowed() bool ` 或 ` reason() string ` 来查验鉴权检查的结果。
324
+
325
+ <!--
326
+ Non-resource authorization performed are used as follows:
327
+
328
+ 1. specify only a path: `Authorizer.path(string) PathCheck`
329
+ 1. Call `PathCheck.check(httpVerb string) Decision` to perform the authorization check.
330
+ 1. Call `allowed() bool` or `reason() string` to inspect the result of the authorization check.
331
+ -->
332
+ 对非资源访问的鉴权过程如下:
333
+
334
+ 1 . 仅指定路径:` Authorizer.path(string) PathCheck `
335
+ 1 . 调用 ` PathCheck.check(httpVerb string) Decision ` 来执行鉴权检查。
336
+ 1 . 调用 ` allowed() bool ` 或 ` reason() string ` 来查验鉴权检查的结果。
337
+
338
+ <!--
339
+ To perform an authorization check for a service account:
340
+ -->
341
+ 对于服务账号执行鉴权检查的方式:
342
+
343
+ - ` Authorizer.serviceAccount(namespace string, name string) Authorizer `
344
+
345
+ <!--
346
+ {{< table caption="Examples of CEL expressions using URL library functions" >}}
347
+ | CEL Expression | Purpose |
348
+ |--------------------------------------------------------------------------------------------------------------|------------------------------------------------|
349
+ | `authorizer.group('').resource('pods').namespace('default').check('create').allowed()` | Returns true if the principal (user or service account) is allowed create pods in the 'default' namespace. |
350
+ | `authorizer.path('/healthz').check('get').allowed()` | Checks if the principal (user or service account) is authorized to make HTTP GET requests to the /healthz API path. |
351
+ | `authorizer.serviceAccount('default', 'myserviceaccount').resource('deployments').check('delete').allowed()` | Checks if the service account is authorized to delete deployments. |
352
+ {{< /table >}}
353
+ -->
354
+ {{< table caption="使用 URL 库函数的 CEL 表达式示例" >}}
355
+ | CEL 表达式 | 用途 |
356
+ | -------------------------------------------------| ------------------------------------------------|
357
+ | ` authorizer.group('').resource('pods').namespace('default').check('create').allowed() ` | 如果主体(用户或服务账号)被允许在 ` default ` 名字空间中创建 Pod,返回 true。 |
358
+ | ` authorizer.path('/healthz').check('get').allowed() ` | 检查主体(用户或服务账号)是否有权限向 /healthz API 路径发出 HTTP GET 请求。 |
359
+ | ` authorizer.serviceAccount('default', 'myserviceaccount').resource('deployments').check('delete').allowed() ` | 检查服务账号是否有权限删除 Deployment。 |
360
+ {{< /table >}}
361
+
362
+ <!--
363
+ See the [Kubernetes Authz library](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz)
364
+ godoc for more information.
365
+ -->
366
+ 更多信息请参阅 Go 文档:
367
+ [ Kubernetes Authz library] ( https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz ) 。
368
+
286
369
<!--
287
370
## Type checking
288
371
@@ -391,7 +474,7 @@ Also see: [CEL types](https://github.com/google/cel-spec/blob/v0.6.0/doc/langdef
391
474
-->
392
475
另见:[ CEL 类型] ( https://github.com/google/cel-spec/blob/v0.6.0/doc/langdef.md#values ) 、
393
476
[ OpenAPI 类型] ( https://swagger.io/specification/#data-types ) 、
394
- [ Kubernetes 结构化模式] ( /docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema ) 。
477
+ [ Kubernetes 结构化模式] ( /zh-cn/ docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema ) 。
395
478
396
479
<!--
397
480
Equality comparison for arrays with `x-kubernetes-list-type` of `set` or `map` ignores element
0 commit comments