如何使用 az-cli 设置分支权限?

How to set branch permissions using az-cli?

我正在尝试拒绝 develop 分支的主题的编辑策略权限。我的印象是这个命令会起作用:

$ az devops security permission update --allow-bit 2048 --subject foo@bar.com --namespace-id ***** --token repoV2/<project id>/<git repo id>/refs^heads^develop/ 

尽管响应

[
  {
    "acesDictionary": {
      "Microsoft.IdentityModel.Claims.ClaimsIdentity;****\foo@bar.com": {
        "allow": 2048,
        "deny": 0,
        "descriptor": "Microsoft.IdentityModel.Claims.ClaimsIdentity;****\foo@bar.com",
        "extendedInfo": {
          "effectiveAllow": 20342
        },
        "resolvedPermissions": [
          {
            "bit": 2048,
            "displayName": "Edit policies",
            "effectivePermission": "Allow",
            "name": "EditPolicies"
          }
        ]
      }
    },
    "includeExtendedInfo": true,
    "inheritPermissions": true,
    "token": "repoV2/***/***/refs^heads^develop"
  }
]

权限保持不变。

我认为令牌和命名空间 ID 是正确的,因为该命令在使用令牌 repoV2/***/***/ 时有效。

az devops security permission update格式如下:

az devops security permission update --id
                                     --subject
                                     --token
                                     [--allow-bit]
                                     [--deny-bit]
                                     [--org]

从你的azure cli命令来看,问题的原因应该是参数。

您可以在浏览器 F12 网络工具中获取这些参数。

步骤如下:

Step1:导航到分支权限,按F12打开NetWork工具。 然后你可以 select 网络选项卡。

第二步:尝试更改权限。

第三步:您可以查看网络记录并获取这些参数。

这里有一个关于 azure cli 的例子:

az devops security permission update --id 2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87 --subject xxx@xxx.com --token repoV2/92c1c5e8-d842-4698-b3f5-45d69e25624c/34439f96-646e-4aa0-a3e5-a55742a9813e/refs/heads/310032003400/ --allow-bit 0 --deny-bit 2048 --org https://dev.azure.com/orgname

注意:token中的branch parameter需要是十六进制的id(例如refs/heads/310032003400/)。

根据我的测试,如果您使用分支名称,它不会更改权限。

这是一张关于 的票。