Azure DevOps Services |Azure DevOps Server |Azure DevOps Server 2022 |Azure DevOps Server 2020
本文介绍如何授予 Azure DevOps 中服务挂钩的 “查看 ”或 “编辑 ”权限。 默认情况下,只有项目管理员拥有这些权限。 若要将其分配给其他用户或组,请使用 命令行工具 或 安全 REST API。
安全 ServiceHooks 命名空间 ID 在 “列出安全命名空间”下定义。
先决条件
| 类别 | 要求 |
|---|---|
| 项目访问权限 | 项目成员. |
| 权限 | - 项目集合管理员组的成员。 组织所有者是此组的自动成员。 - Microsoft Entra 令牌或个人访问令牌 (PAT) 用于 Azure DevOps 配置文件。 > [!重要提示] > 我们推荐使用更安全的 Microsoft Entra 令牌 ,而非风险较高的 个人访问令牌。 详细了解我们 减少 PAT 使用率的努力。 > 查看我们的 身份验证指南 ,以根据需要选择正确的身份验证机制。 |
| 工具 |
Azure CLI。 1. 使用 az devops login登录。2.可以将组织定义为默认组织。 否则,请为每个命令定义 --org "https://dev.azure.com/{organization}" 。 az devops configure --defaults organization="https://dev.azure.com/{organization}"3.检查是否可以查看组织的权限列表: az devops security permission namespace list --org "https://dev.azure.com/{organization}"。 |
读取组标识和权限令牌
查找组标识描述符。
> az devops security group list --project 00000000-0000-0000-0000-000000000000 --output table Name Descriptor ----------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------- [TEAM FOUNDATION]\EntraServiceHooksRead Aa1Bb~2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_Jj0Kk1Ll2如果要按组名称进行筛选,可以使用
findstr或grep命令取决于命令提示符。获取权限令牌。
> az devops security permission list --id 00000000-0000-0000-0000-000000000000 --subject <Group or user descriptor> --output table Token Effective Allow Effective Deny ------------------------------------------------------ ----------------- ---------------- PublisherSecurity 0 0 PublisherSecurity/00000000-0000-0000-0000-000000000000 0 0
更新服务挂钩的读取权限
可为其
--allow-bit定义的权限列表。- 查看订阅
- 编辑订阅
- 删除订阅
- 发布事件
> az devops security permission namespace show --id 00000000-0000-0000-0000-000000000000 { "actions": [ { "bit": 1, "displayName": "View Subscriptions", "name": "ViewSubscriptions", "namespaceId": "00000000-0000-0000-0000-000000000000" }, { "bit": 2, "displayName": "Edit Subscription", "name": "EditSubscriptions", "namespaceId": "00000000-0000-0000-0000-000000000000" }, { "bit": 4, "displayName": "Delete Subscriptions", "name": "DeleteSubscriptions", "namespaceId": "00000000-0000-0000-0000-000000000000" }, { "bit": 8, "displayName": "Publish Events", "name": "PublishEvents", "namespaceId": "00000000-0000-0000-0000-000000000000" } ], "dataspaceCategory": "Default", "displayName": "ServiceHooks", "elementLength": -1, "extensionType": null, "isRemotable": true, "name": "ServiceHooks", "namespaceId": "00000000-0000-0000-0000-000000000000", "readPermission": 1, "separatorValue": "/", "structureValue": 1, "systemBitMask": 0, "useTokenTranslator": true, "writePermission": 7 }设置 组的“视图 ”访问权限。 查看 ServiceHooks 订阅等于 1。
--allow-bit> az devops security permission update --namespace-id 00000000-0000-0000-0000-000000000000 --subject <Group or user descriptor> --token PublisherSecurity/00000000-0000-0000-0000-000000000000 --allow-bit 1 [ { "acesDictionary": { "Microsoft.TeamFoundation.Identity;00000000-0000-0000-0000-000000000000": { "allow": 1, "deny": 0, "descriptor": "Microsoft.TeamFoundation.Identity;00000000-0000-0000-0000-000000000000", "extendedInfo": { "effectiveAllow": 1 }, "resolvedPermissions": [ { "bit": 1, "displayName": "View Subscriptions", "effectivePermission": "Allow", "name": "ViewSubscriptions" } ] } }, "includeExtendedInfo": true, "inheritPermissions": true, "token": "PublisherSecurity/00000000-0000-0000-0000-000000000000" } ]获取权限令牌以查看更改。
> az devops security permission list --id 00000000-0000-0000-0000-000000000000 --subject <Group or user descriptor> --output table Token Effective Allow Effective Deny ------------------------------------------------------ ----------------- ---------------- PublisherSecurity 0 0 PublisherSecurity/00000000-0000-0000-0000-000000000000 1 0
以下示例显示用户可以看到服务挂钩订阅。
重置组的所有服务挂钩权限
如果需要重置组或用户的所有服务挂钩权限,可以调用
reset-all。> az devops security permission reset-all --id 00000000-0000-0000-0000-000000000000 --subject <Group or user descriptor> --token PublisherSecurity/00000000-0000-0000-0000-000000000000 Are you sure you want to reset all explicit permissions for this user/group and token? (y/n): Y true > az devops security permission list --id 00000000-0000-0000-0000-000000000000 --subject <Group or user descriptor> --output table Token Effective Allow Effective Deny ------------------------------------------------------ ----------------- ---------------- PublisherSecurity 0 0 PublisherSecurity/00000000-0000-0000-0000-000000000000 0 0以下示例显示用户在重置权限后无法查看服务挂钩订阅。