SelfSubjectAccessReview
apiVersion: authorization.k8s.io/v1
import "k8s.io/api/authorization/v1"
SelfSubjectAccessReview
SelfSubjectAccessReview 检查当前用户是否可以执行某个操作。不填写 spec.namespace 表示“在所有名字空间中”。Self 是一个特例,因为用户应该总是能够检查他们是否可以执行某个操作
apiVersion: authorization.k8s.io/v1
kind: SelfSubjectAccessReview
metadata (ObjectMeta)
标准列表元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec (SelfSubjectAccessReviewSpec),必需
Spec 包含了关于正在评估的请求的信息。user 和 groups 必须为空
status (SubjectAccessReviewStatus)
Status 由服务器填充,表示请求是否被允许
SelfSubjectAccessReviewSpec
SelfSubjectAccessReviewSpec 是对访问请求的描述。ResourceAuthorizationAttributes 和 NonResourceAuthorizationAttributes 中必须且只能设置一个
nonResourceAttributes (NonResourceAttributes)
NonResourceAttributes 描述了非资源访问请求的信息
NonResourceAttributes 包含对 Authorizer 接口发起的非资源请求可用的授权属性
nonResourceAttributes.path (string)
Path 是请求的 URL 路径
nonResourceAttributes.verb (string)
Verb 是标准的 HTTP 动词
resourceAttributes (ResourceAttributes)
ResourceAuthorizationAttributes 描述了资源访问请求的信息
ResourceAttributes 包含对 Authorizer 接口发起的资源请求可用的授权属性
resourceAttributes.fieldSelector (FieldSelectorAttributes)
fieldSelector 描述了基于字段对访问施加的限制。它只能限制访问,不能扩大访问范围。
此字段处于 Alpha 阶段。要使用此字段,必须启用
AuthorizeWithSelectors
特性门控(默认为禁用)。*FieldSelectorAttributes 指示受字段限制的访问。鼓励 Webhook 的作者:* 确保 rawSelector 和 requirements 不同时设置 * 如果设置了 requirements 字段,则考虑该字段 * 如果设置了 rawSelector 字段,则不要尝试解析或考虑该字段。这是为了避免另一个 CVE-2022-2880(即,让不同的系统就如何精确解析查询达成一致是我们不希望发生的事情),有关更多详细信息,请参阅 https://www.oxeye.io/resources/golang-parameter-smuggling-attack。对于 kube-apiserver 的 *SubjectAccessReview 端点:* 如果 rawSelector 为空且 requirements 为空,则请求不受限制。* 如果 rawSelector 存在且 requirements 为空,如果解析成功,rawSelector 将被解析并限制。* 如果 rawSelector 为空且 requirements 存在,则应遵守 requirements。* 如果 rawSelector 存在且 requirements 存在,则请求无效。*
resourceAttributes.fieldSelector.rawSelector (string)
rawSelector 是字段选择器的序列化形式,通常包含在查询参数中。鼓励 Webhook 实现忽略 rawSelector。只要 requirements 不存在,kube-apiserver 的 *SubjectAccessReview 将解析 rawSelector。
resourceAttributes.fieldSelector.requirements ([]FieldSelectorRequirement)
原子性:将在合并期间被替换
requirements 是字段选择器的解析解释。资源实例必须满足所有 requirements 才能匹配选择器。Webhook 实现应该处理 requirements,但如何处理取决于 Webhook。由于 requirements 只能限制请求,因此如果 requirements 未被理解,授权为不受限制的请求是安全的。
FieldSelectorRequirement 是一个选择器,包含值、键和关联键与值的操作符。
resourceAttributes.fieldSelector.requirements.key (string),必需
key 是 requirement 应用的字段选择器键。
resourceAttributes.fieldSelector.requirements.operator (string),必需
operator 表示键与一组值之间的关系。有效的操作符包括 In、NotIn、Exists、DoesNotExist。操作符列表将来可能会增加。
resourceAttributes.fieldSelector.requirements.values ([]string)
原子性:将在合并期间被替换
values 是一个字符串值数组。如果操作符是 In 或 NotIn,values 数组必须非空。如果操作符是 Exists 或 DoesNotExist,values 数组必须为空。
resourceAttributes.group (string)
Group 是资源的 API Group。“*”表示所有。
resourceAttributes.labelSelector (LabelSelectorAttributes)
labelSelector 描述了基于标签对访问施加的限制。它只能限制访问,不能扩大访问范围。
此字段处于 Alpha 阶段。要使用此字段,必须启用
AuthorizeWithSelectors
特性门控(默认为禁用)。*LabelSelectorAttributes 指示受标签限制的访问。鼓励 Webhook 的作者:* 确保 rawSelector 和 requirements 不同时设置 * 如果设置了 requirements 字段,则考虑该字段 * 如果设置了 rawSelector 字段,则不要尝试解析或考虑该字段。这是为了避免另一个 CVE-2022-2880(即,让不同的系统就如何精确解析查询达成一致是我们不希望发生的事情),有关更多详细信息,请参阅 https://www.oxeye.io/resources/golang-parameter-smuggling-attack。对于 kube-apiserver 的 *SubjectAccessReview 端点:* 如果 rawSelector 为空且 requirements 为空,则请求不受限制。* 如果 rawSelector 存在且 requirements 为空,如果解析成功,rawSelector 将被解析并限制。* 如果 rawSelector 为空且 requirements 存在,则应遵守 requirements。* 如果 rawSelector 存在且 requirements 存在,则请求无效。*
resourceAttributes.labelSelector.rawSelector (string)
rawSelector 是字段选择器的序列化形式,通常包含在查询参数中。鼓励 Webhook 实现忽略 rawSelector。只要 requirements 不存在,kube-apiserver 的 *SubjectAccessReview 将解析 rawSelector。
resourceAttributes.labelSelector.requirements ([]LabelSelectorRequirement)
原子性:将在合并期间被替换
requirements 是标签选择器的解析解释。资源实例必须满足所有 requirements 才能匹配选择器。Webhook 实现应该处理 requirements,但如何处理取决于 Webhook。由于 requirements 只能限制请求,因此如果 requirements 未被理解,授权为不受限制的请求是安全的。
标签选择器 Requirement 是一个选择器,包含值、键和关联键与值的操作符。
resourceAttributes.labelSelector.requirements.key (string),必需
key 是选择器应用的标签键。
resourceAttributes.labelSelector.requirements.operator (string),必需
operator 表示键与一组值之间的关系。有效的操作符包括 In、NotIn、Exists 和 DoesNotExist。
resourceAttributes.labelSelector.requirements.values ([]string)
原子性:将在合并期间被替换
values 是一个字符串值数组。如果操作符是 In 或 NotIn,values 数组必须非空。如果操作符是 Exists 或 DoesNotExist,values 数组必须为空。该数组在策略性合并补丁期间会被替换。
resourceAttributes.name (string)
Name 是请求“get”操作时资源的名称,或请求“delete”操作时待删除资源的名称。“”(空)表示所有。
resourceAttributes.namespace (string)
Namespace 是请求操作所属的名字空间。目前,没有名字空间和所有名字空间之间没有区别。“”(空)是 LocalSubjectAccessReviews 的默认值。“”(空)对于集群范围资源是空的。“”(空)对于来自 SubjectAccessReview 或 SelfSubjectAccessReview 的名字空间范围资源表示“所有”。
resourceAttributes.resource (string)
Resource 是现有资源类型之一。“*”表示所有。
resourceAttributes.subresource (string)
Subresource 是现有资源类型之一。“”表示无。
resourceAttributes.verb (string)
Verb 是 Kubernetes 资源 API 动词,例如:get、list、watch、create、update、delete、proxy。“*”表示所有。
resourceAttributes.version (string)
Version 是资源的 API 版本。“*”表示所有。
操作
create
创建一个 SelfSubjectAccessReview
HTTP 请求
POST /apis/authorization.k8s.io/v1/selfsubjectaccessreviews
参数
body: SelfSubjectAccessReview,必需
dryRun (查询参数): string
fieldManager (查询参数): string
fieldValidation (查询参数): string
pretty (查询参数): string
响应
200 (SelfSubjectAccessReview): 成功 (OK)
201 (SelfSubjectAccessReview): 已创建 (Created)
202 (SelfSubjectAccessReview): 已接受 (Accepted)
401: 未授权
本页面是自动生成的。
如果你打算报告关于本页面的问题,请在问题描述中提及本页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。