*
为用户绑定角色(推荐)
请求信息
请求行
POST /auth/v2/userbindings
请求体
Content-Type
application/json
请求体示例
Userbinding 的请求体。
{
"constraint": {
"cluster": "cluster-name",
"namespace": "ns-name",
"project": "proj-name"
},
"role": "namespace-admin-system",
"scope": "namespace",
"subject": {
"kind": "User",
"name": "user@example.com"
}
}
请求体说明
名称 | 类型 | 是否必填项 | 描述 |
---|---|---|---|
constraint | object | 是 |
角色绑定资源约束。
字段路径:constraint |
constraint.cluster | string | 是 |
待绑定集群的名称。
字段路径:constraint.cluster |
constraint.namespace | string | 是 |
命名空间名称。
字段路径:constraint.namespace |
constraint.project | string | 是 |
待绑定项目的名称。
字段路径:constraint.project |
role | string | 是 |
绑定的角色的名称。
字段路径:role |
scope | string | 是 |
绑定范围,支持 platform(平台)、cluster(集群)project(项目)和 namespace(命名空间)。
字段路径:scope |
subject | object | 是 |
绑定的主体的信息。
字段路径:subject |
subject.kind | string | 是 |
绑定的主体的类型,支持“User”。
字段路径:subject.kind |
subject.name | string | 是 |
主体的名称,例如:用户的用户名。
字段路径:subject.name |
返回信息
Content-Type
application/json
状态码: 201
OK
返回体示例
为用户绑定角色的请求体示例。
{
"apiVersion": "auth.alauda.io/v1",
"kind": "UserBinding",
"metadata": {
"creationTimestamp": "2020-05-23T02:33:04Z",
"labels": {
"alauda.io/cluster": "cluster-name",
"alauda.io/namespace": "ns-name",
"alauda.io/project": "proj-name",
"auth.alauda.io/role.level": "namespace",
"auth.alauda.io/role.name": "namespace-admin-system",
"auth.alauda.io/user.email": "b58996c504c5638798eb6b511e6f49af"
},
"name": "b58996c504c5638798eb6b511e6f49af-xsdww"
},
"spec": {
"constraint": {
"cluster": "cluster-name",
"namespace": "ns-name",
"project": "proj-name"
},
"roleRef": "namespace-admin-system",
"scope": "namespace",
"subjects": [
{
"kind": "User",
"name": "user@example.com"
}
]
}
}
返回体说明
名称 | 类型 | 描述 |
---|---|---|
apiVersion | string | 查看公共参数 |
kind | string | 查看公共参数 |
metadata | object | 查看公共参数 |