分享方式:


在服務勾點中設定群組的檢視許可權

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

根據預設,只有 [專案管理員] 具有 [檢視 ] 或 [編輯 ] 許可權。 若要直接將這些許可權授與其他使用者,您可以使用 命令行工具安全性 REST API。

顯示 [ServiceHook] 頁面沒有許可權的螢幕快照。

安全性ServiceHooks命名空間識別碼定義於 [列出安全性命名空間] 底下cb594ebe-87dd-4fc9-ac2c-6a10a4c92046

必要條件

  1. 安裝 Azure CLI 以執行 az devops 命令。 如何安裝 Azure CLI

  2. 為您的 Azure DevOps 設定檔建立個人存取令牌 (PAT )。 請確定您是專案集合管理員 (PCA) 群組的成員

    • 身分識別(讀取)
    • 圖表 (讀取)
    • 安全性(管理)
  3. 使用 az devops login登入 Azure DevOps。 如果您沒有擴充功能 az devops ,請加以安裝。

    > az devops login
    The command requires the extension azure-devops. Do you want to install it now? The command will continue to run after the extension is installed. (Y/n): Y
    
  4. 您可以將組織定義為預設組織。 否則,請為每個指令定義 --org "https://dev.azure.com/{organization}"

    az devops configure --defaults organization="https://dev.azure.com/{organization}"
    
  5. 檢查您是否可以看到組織的許可權清單。

    az devops security permission namespace list --org "https://dev.azure.com/{organization}"
    

讀取群組身分識別和許可權令牌

  1. 尋找您的群組身分識別描述元。

    > az devops security group list --project ac515e82-560c-4af8-845b-9f7f968d8e7b --output table
    
    Name                                             Descriptor
    -----------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------
    [TEAM FOUNDATION]\EntraServiceHooksRead          aadgp.Uy0xLTktMTU1MTM3NDI0NS0xMjA0NDAwOTY5LTI0MDI5ODY0MTMtMjE3OTQwODYxNi0zLTM5NTQxNzM3ODYtMTUyMTA4MTkyNS0yNTQwNTA4MjYzLTMzNDgxNjQxNjg
    

    如果您想要依組名進行篩選,您可以使用 findstrgrep 命令,視您的命令提示字元而定。

  2. 取得許可權令牌。

    > az devops security permission list --id cb594ebe-87dd-4fc9-ac2c-6a10a4c92046 --subject <Group or user descriptor> --output table
    
    Token                                                   Effective Allow    Effective Deny
    ------------------------------------------------------  -----------------  ----------------
    PublisherSecurity                                       0                  0
    PublisherSecurity/ac515e82-560c-4af8-845b-9f7f968d8e7b  0                  0
    

更新服務攔截的讀取許可權

  1. 您可以為 --allow-bit定義之可能的許可權清單。

    • 檢視訂閱
    • 編輯訂閱
    • 刪除訂閱
    • 發佈事件
    > az devops security permission namespace show --id cb594ebe-87dd-4fc9-ac2c-6a10a4c92046
    
    [
      {
        "actions": [
          {
            "bit": 1,
            "displayName": "View Subscriptions",
            "name": "ViewSubscriptions",
            "namespaceId": "cb594ebe-87dd-4fc9-ac2c-6a10a4c92046"
          },
          {
            "bit": 2,
            "displayName": "Edit Subscription",
            "name": "EditSubscriptions",
            "namespaceId": "cb594ebe-87dd-4fc9-ac2c-6a10a4c92046"
          },
          {
            "bit": 4,
            "displayName": "Delete Subscriptions",
            "name": "DeleteSubscriptions",
            "namespaceId": "cb594ebe-87dd-4fc9-ac2c-6a10a4c92046"
          },
          {
            "bit": 8,
            "displayName": "Publish Events",
            "name": "PublishEvents",
            "namespaceId": "cb594ebe-87dd-4fc9-ac2c-6a10a4c92046"
          }
        ],
        "dataspaceCategory": "Default",
        "displayName": "ServiceHooks",
        "elementLength": -1,
        "extensionType": null,
        "isRemotable": true,
        "name": "ServiceHooks",
        "namespaceId": "cb594ebe-87dd-4fc9-ac2c-6a10a4c92046",
        "readPermission": 1,
        "separatorValue": "/",
        "structureValue": 1,
        "systemBitMask": 0,
        "useTokenTranslator": true,
        "writePermission": 7
      }
    
  2. 設定 群組的檢視 存取權。 檢視 ServiceHooks 訂閱等於 的 1 --allow-bit

    > az devops security permission update --namespace-id cb594ebe-87dd-4fc9-ac2c-6a10a4c92046 --subject <Group or user descriptor> --token PublisherSecurity/ac515e82-560c-4af8-845b-9f7f968d8e7b --allow-bit 1
    
    [
      {
        "acesDictionary": {
          "Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1204400969-2402986413-2179408616-3-3954173786-1521081925-2540508263-3348164168": {
            "allow": 1,
            "deny": 0,
            "descriptor": "Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1204400969-2402986413-2179408616-3-3954173786-1521081925-2540508263-3348164168",
            "extendedInfo": {
              "effectiveAllow": 1
            },
            "resolvedPermissions": [
              {
                "bit": 1,
                "displayName": "View Subscriptions",
                "effectivePermission": "Allow",
                "name": "ViewSubscriptions"
              }
            ]
          }
        },
        "includeExtendedInfo": true,
        "inheritPermissions": true,
        "token": "PublisherSecurity/ac515e82-560c-4af8-845b-9f7f968d8e7b"
      }
    ]
    
  3. 取得許可權令牌以查看您的變更。

    > az devops security permission list --id cb594ebe-87dd-4fc9-ac2c-6a10a4c92046 --subject <Group or user descriptor> --output table
    
    Token                                                   Effective Allow    Effective Deny
    ------------------------------------------------------  -----------------  ----------------
    PublisherSecurity                                       0                  0
    PublisherSecurity/ac515e82-560c-4af8-845b-9f7f968d8e7b  1                  0
    

下列範例顯示使用者可以看到服務勾點訂用帳戶。

此螢幕快照顯示具有許可權的 ServiceHooks 頁面。

重設群組的所有服務攔截許可權

  • 如果您需要重設群組或使用者的所有服務攔截許可權,您可以呼叫 reset-all

    > az devops security permission reset-all --id cb594ebe-87dd-4fc9-ac2c-6a10a4c92046 --subject <Group or user descriptor> --token PublisherSecurity/ac515e82-560c-4af8-845b-9f7f968d8e7b
    
    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 cb594ebe-87dd-4fc9-ac2c-6a10a4c92046 --subject <Group or user descriptor> --output table
    Token                                                   Effective Allow    Effective Deny
    ------------------------------------------------------  -----------------  ----------------
    PublisherSecurity                                       0                  0
    PublisherSecurity/ac515e82-560c-4af8-845b-9f7f968d8e7b  0                  0
    
  • 下列範例顯示用戶無法在重設許可權之後檢視服務勾點訂閱。

    顯示 [ServiceHook] 頁面未經許可權的螢幕快照。