# 访问控制
如果使用 project_full_path,确保 project_full_path 编码过,例子:/api/v3/projects/tencent/code--> /api/v3/projects/tencent%2Fcode (/ 编码 %2F)
# 获取访问控制配置
查看项目的访问控制配置。(包括 IP 白名单、用户白名单、特定访问规则 IP 白名单、特定访问规则用户白名单)
GET /api/v3/projects/:id/acl/config
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
返回值:
{
"project_id": 1,
"acl_enabled": true,
"allow_ips": "127.0.0.1;30.20.165.0/24",
"allow_users": "git_01;git_02",
"spec_allow_ips": "30.20.165.46",
"spec_hit_users": "git_03"
}
# 更新项目 ACL 开关
打开、关闭项目访问控制开关
PUT /api/v3/projects/:id/acl/config/acl_enabled
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| acl_enabled | boolean | 项目 ACL 开关 (默认 false) |
返回值:
{
"project_id": 1,
"acl_enabled": false,
"allow_ips": "127.0.0.1;30.20.165.0/24",
"allow_users": "git_01;git_02",
"spec_allow_ips": "30.20.165.46",
"spec_hit_users": "git_03"
}
# 更新项目 IP 白名单
更新项目访问控制中的 IP 白名单
PUT /api/v3/projects/:id/acl/config/allow_ips
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| allow_ips | string | 项目 IP 白名单 (如有多个请用英文";"分隔) |
返回值:
{
"project_id": 1,
"acl_enabled": true,
"allow_ips": "127.0.0.1;30.20.165.0/24",
"allow_users": "git_01;git_02",
"spec_allow_ips": "30.20.165.46",
"spec_hit_users": "git_03"
}
# 更新项目用户白名单
更新项目访问控制中的用户白名单
PUT /api/v3/projects/:id/acl/config/allow_users
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| allow_users | string | 项目用户白名单 (如有多个请用英文";"分隔) |
返回值:
{
"project_id": 1,
"acl_enabled": true,
"allow_ips": "127.0.0.1;30.20.165.0/24",
"allow_users": "git_01;git_02",
"spec_allow_ips": "30.20.165.46",
"spec_hit_users": "git_03"
}
# 更新项目特定访问规则 IP 白名单
更新项目访问控制中的特定访问规则 IP 白名单
PUT /api/v3/projects/:id/acl/config/spec_allow_ips
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| spec_allow_ips | string | 项目特定访问规则 IP 白名单 (如有多个请用英文";"分隔) |
返回值:
{
"project_id": 1,
"acl_enabled": true,
"allow_ips": "127.0.0.1;30.20.165.0/24",
"allow_users": "git_01;git_02",
"spec_allow_ips": "30.20.165.46",
"spec_hit_users": "git_03"
}
# 更新项目特定访问规则用户白名单
更新项目访问控制中的特定访问规则用户白名单
PUT /api/v3/projects/:id/acl/config/spec_hit_users
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| spec_hit_users | string | 项目特定访问规则用户白名单 (如有多个请用英文";"分隔) |
返回值:
{
"project_id": 1,
"acl_enabled": true,
"allow_ips": "127.0.0.1;30.20.165.0/24",
"allow_users": "git_01;git_02",
"spec_allow_ips": "30.20.165.46",
"spec_hit_users": "git_03"
}