Home / API Documentation / Platform management / Users / User binding role / Binding roles for users (recommended)

*Binding roles for users (recommended)

Requests

HTTP request

POST /auth/v2/userbindings

Request body

Content-Type application/json

Sample request

userbinding body

{
   "constraint": {
     "cluster": "cluster-name",
     "namespace": "ns-name",
     "project": "proj-name"
   },
   "role": "namespace-admin-system",
   "scope": "namespace",
   "subject": {
     "kind": "User",
     "name": "user@example.com"
   }
 }

Parmeters

Name Type Required Description
constraint object True Role binding resource constraints
Path: constraint
constraint.cluster string True Cluster to which namespace belongs
Path: constraint.cluster
constraint.namespace string True Namespace of the project to which it belongs
Path: constraint.namespace
constraint.project string True Name of the project to be bound
Path: constraint.project
role string True Binding role name
Path: role
scope string True Binding scope, supporting platform, cluster, project and namespace
Path: scope
subject object True Binding subject
Path: subject
subject.kind string True Subject type, "User" supported
Path: subject.kind
subject.name string True Subject name, such as user email
Path: subject.name

Responses

Content-Type application/json

Status code: 201

OK

Sample response

userbinding for bind permission for user

{
   "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"
       }
     ]
   }
 }

Parameters

Name Type Description
apiVersion string See common parameters
kind string See common parameters
metadata object See common parameters

Other status codes