Skip to content

Latest commit

 

History

History
518 lines (416 loc) · 11.7 KB

permission.md

File metadata and controls

518 lines (416 loc) · 11.7 KB

bkrepo 权限相关接口

创建权限

  • API: POST /auth/api/permission/create

  • API 名称: create_permission

  • 功能说明:

    • 中文:创建权限
    • English:create permission
  • input body:

{
    "createBy":"owen",
    "excludePattern":[
        "/index"
    ],
    "includePattern":[
        "/path1"
    ],
    "permName":"perm1",
    "projectId":"ops",
    "repos":[
        "owen"
    ],
    "resourceType":"PROJECT",
    "roles":[
        "abcdef"
    ],
    "users":[
        "owen"
    ],
    "departments":[
        "1",
        "2"
    ],
    "actions":"MANAGE"
}
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
createBy string 创建人 the man create it
excludePattern string array empty array 排除路径 the exclude path
includePattern string array empty array 包含路径 the include path
projectId string null 项目ID the project id
repos string array empty array 关联仓库列表 the associate repo list
resourceType ENUM REPO 权限类型[REPO,PROJECT,SYSTEM,NODE] permission type [REPO,PROJECT,SYSTEM,NODE]
users string array empty array 权限授权用户 the auth user
roles string array empty array 权限授权角色 the auth role
departments string array empty array 权限授权角色 the auth department
  • output:
{
    "code":0,
    "message":null,
    "data":true,
    "traceId":""
}

  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data bool result data the data for response
traceId string 请求跟踪id the trace id

删除权限

  • API: DELETE /auth/api/permission/delete/{id}

  • API 名称: delete_permission

  • 功能说明:

    • 中文:删除权限
    • English:delete permission
  • input body:

  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
id string 权限主键ID the permission key id
  • output:
{
    "code":0,
    "message":null,
    "data":true,
    "traceId":""
}

  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data bool result data the data for response
traceId string 请求跟踪id the trace id

校验权限

  • API: POST /auth/api/permission/check

  • API 名称: check_permission

  • 功能说明:

    • 中文:校验权限
    • English:check permission
  • input body:

{
    "action":"MANAGE",
    "path":"/index",
    "projectId":"ops",
    "repoName":"docker-local",
    "resourceType":"PROJECT",
    "uid":"owen"
}

  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
action ENUM 动作 the action
path string 路径 the path
projectId string 项目ID the project id
repoName string 仓库名 the name of repo
resourceType ENUM REPO 权限类型[REPO,PROJECT,SYSTEM,NODE] permission type [REPO,PROJECT,SYSTEM,NODE]
uid string 用户ID the user id
  • output:
{
    "code":0,
    "message":null,
    "data":true,
    "traceId":""
}

  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data bool result data the data for response
traceId string 请求跟踪id the trace id

校验管理员

  • API: GET /auth/api/permission/checkAdmin/{uid}

  • API 名称: check_admin

  • 功能说明:

    • 中文:校验管理员权限
    • English:check admin permission
  • input body:

  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
uid string 用户ID the user id
  • output:
{
    "code":0,
    "message":null,
    "data":true,
    "traceId":""
}

  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data bool result data the data for response
traceId string 请求跟踪id the trace id

仓库内置权限列表

  • API: GET /auth/api/permission/list/inrepo?projectId=ops&repoName=repo
  • API 名称: list_permission
  • 功能说明:
    • 中文:权限列表
    • English:the permission list
  • input body:
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
projectId string 项目ID the project id
repoName string 仓库名称 the repo name
resourceType ENUM 权限类型[REPO,PROJECT,SYSTEM,NODE] permission type [REPO,PROJECT,SYSTEM,NODE]
  • output:
{
  "code": 0,
  "message": null,
  "data": [
    {
      "id": "5fbcc9d85fe04f126a508a3a",
      "resourceType": "REPO",
      "projectId": "ops",
      "permName": "repo_admin",
      "repos": [
        "generic"
      ],
      "includePattern": [],
      "excludePattern": [],
      "users": [],
      "roles": [],
      "departments": [],
      "actions": [],
      "createBy": "admin",
      "updatedBy": "admin",
      "createAt": "2020-11-24T16:52:40.575",
      "updateAt": "2020-11-24T16:52:40.575"
    },
    {
      "id": "5fbcc9d85fe04f126a508a3b",
      "resourceType": "REPO",
      "projectId": "ops",
      "permName": "repo_user",
      "repos": [
        "generic"
      ],
      "includePattern": [],
      "excludePattern": [],
      "users": [],
      "roles": [],
      "departments": [],
      "actions": [],
      "createBy": "admin",
      "updatedBy": "admin",
      "createAt": "2020-11-24T16:52:40.678",
      "updateAt": "2020-11-24T16:52:40.678"
    },
    {
      "id": "5fbcc9d85fe04f126a508a3c",
      "resourceType": "REPO",
      "projectId": "ops",
      "permName": "repo_viewer",
      "repos": [
        "generic"
      ],
      "includePattern": [],
      "excludePattern": [],
      "users": [],
      "roles": [],
      "departments": [],
      "actions": [],
      "createBy": "admin",
      "updatedBy": "admin",
      "createAt": "2020-11-24T16:52:40.704",
      "updateAt": "2020-11-24T16:52:40.704"
    }
  ],
  "traceId": ""
}


  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data object array result data,具体字段见创建请求 the data for response
traceId string 请求跟踪id the trace id
  • data 字段说明
字段 类型 说明 Description
users string array 用户id the user id
roles string array 用户组id the role id
departments string array 部门id the department id
actions string array action id the action id

权限列表

  • API: GET /auth/api/permission/list?projectId=ops&repoName=repo&resourceType=REPO
  • API 名称: list_permission
  • 功能说明:
    • 中文:权限列表
    • English:the permission list
  • input body:
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
projectId string 项目ID the project id
repoName string null 仓库名称 the repo name
resourceType string 资源类型 the resource tyep
  • output:
{
    "code":0,
    "data":[
        {
            "createAt":"2019-12-21T09:46:37.792Z",
            "createBy":"string",
            "excludePattern":[
                "/index"
            ],
            "id":"5ea4f6608c165f702f5bd41e",
            "includePattern":[
                "/path1"
            ],
            "permName":"perm1",
            "projectId":"ops",
            "repos":[
                "docker-local"
            ],
            "resourceType":"REPO",
            "roles":[
                "owen",
                "tt"
            ],
            "users":[
                "op",
                "dev"
            ],
            "departments":[
                "1",
                "2"
            ],
            "actions":[
                "MANAGE",
                "READ"
            ],
            "updateAt":"2019-12-21T09:46:37.792Z",
            "updatedBy":"string"
        }
    ],
    "message":"string",
    "traceId":"string"
}


  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data object array result data,具体字段见创建请求 the data for response
traceId string 请求跟踪id the trace id
  • data 字段说明
字段 类型 说明 Description
users string array 用户id the user id
roles string array 用户组id the role id
departments string array 部门id the department id
actions string array action id the action id

更新权限绑定用户

  • API:PUT /auth/api/permission/user

  • API 名称: update_permission_user

  • 功能说明:

    • 中文:更新权限绑定用户
    • English:update permission user
  • input body:

{
    "permissionId":"5ea4f6608c165f702f5bd41e",
    "userId":[
        "owen",
        "tt"
    ]
}
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
permissionId string 角色主键id the permission primary key
userId string array [] 用户id列表 the user id array
  • output:
{
    "code":0,
    "data":true,
    "message":"",
    "traceId":""
}


  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data bool the request result the request result
traceId string 请求跟踪id the trace id

更新仓库下配置的权限

  • API:PUT /auth/api/permission/update/config

  • API 名称: 更新仓库下配置的权限

  • 功能说明:

    • 中文:更新仓库下配置的权限
    • English:update permission
  • input body:

{
    "permissionId":"5ea4f6608c165f702f5bd41e",
    "path":[
        "/ops",
        "/dev"
    ],
    "users": [
    	"test"
    ],
    "name": "perm1",
    "projectId": "blueking"
}
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
permissionId string 角色主键id the permission primary key
path string array 更新权限包含路径 the department id array
users string array 绑定用户 the userName
name string 权限名称 the permission name
projectId string 项目名称 the project Id
  • output:
{
    "code":0,
    "data":true,
    "message":"",
    "traceId":""
}

  • output 字段说明
字段 类型 说明 Description
code bool 错误编码。 0表示success,>0表示失败错误 0:success, other: failure
message result message 错误消息 the failure message
data bool the request result the request result
traceId string 请求跟踪id the trace id