在 Privileged Access Manager 中查看、更新及刪除授權

建立授權後,您可以查看、更新或刪除授權。

事前準備

請確認您已啟用 Privileged Access Manager 並設定相關權限

使用 Google Cloud 控制台查看、更新及刪除授權

  1. 前往「Privileged Access Manager」頁面。

    前往 Privileged Access Manager

  2. 選取要管理權利的機構、資料夾或專案。

  3. 在「權利」分頁中,按一下「所有使用者的權利」分頁。 您可以在這裡查看可用的授權、授權授予的角色,以及有效的要求者和核准者。

  4. 在表格中,找到要檢查的授權,然後按一下該列中的「更多選項」

    • 如要查看授權詳細資料,請按一下「查看授權詳細資料」

    • 如要查看與授權相關的授予項目,請按一下「查看相關聯的授予項目」

    • 如要撤銷授權的所有有效授予項目,請按一下「撤銷所有授予項目」

    • 如要刪除權利,請按一下「刪除權利」。您無法刪除有有效授權的權利。您必須先撤銷授權。

  5. 如要更新權利,請在要更新的權利所在資料列中,按一下「編輯權利」

    更新授權時,請注意下列事項:

    • 更新後的授權設定只會套用至更新後要求的授予項目。不過,核准者變更也會套用至尚未核准或拒絕的現有授權要求。

    • 更新權利時,無法變更是否需要核准。如要變更核准狀態,請改為建立新的授權。

    • 變更權利要求者和核准者可能需要幾分鐘才會生效

透過程式輔助方式查看授權

如要以程式輔助方式查看授權,您可以搜尋、列出、取得及匯出授權。

列出授權

gcloud

gcloud pam entitlements list 指令會列出屬於特定範圍的權利。

使用下方的任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:選用。權利所屬的資源類型。請使用 organizationfolderproject 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理權限的 Google Cloud專案、資料夾或機構的 ID。專案 ID 為英數字串,例如 my-project。 資料夾和機構 ID 是數字,例如 123456789012

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam entitlements list \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam entitlements list `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam entitlements list ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

additionalNotificationTargets:
  adminEmailRecipients:
  - alex@example.com
createTime: '2024-03-26T11:07:37.009498890Z'
eligibleUsers:
- principals:
  - user:bola@example.com
etag: 00000000000000000000000000000000000000000000000000000000000=
maxRequestDuration: 3600s
name: projects/my-project/locations/global/entitlements/ENTITLEMENT_ID
privilegedAccess:
  gcpIamAccess:
    resource: //cloudresourcemanager.googleapis.com/projects/my-project
    resourceType: cloudresourcemanager.googleapis.com/Project
    roleBindings:
    - role: roles/storage.admin
requesterJustificationConfig:
  unstructured: {}
state: AVAILABLE
updateTime: '2024-03-26T11:07:40.056780645Z'

REST

Privileged Access Manager API 的 listEntitlements 方法會列出屬於特定範圍的權利。

使用任何要求資料之前,請先替換以下項目:

  • SCOPE:權利所在的機構、資料夾或專案,格式為 organizations/ORGANIZATION_IDfolders/FOLDER_IDprojects/PROJECT_ID。專案 ID 為英數字串,例如 my-project。資料夾和機構 ID 為數字,例如 123456789012
  • FILTER:選用。傳回欄位值符合 AIP-160 運算式的授權。
  • PAGE_SIZE:選用。要在回應中傳回的項目數。
  • PAGE_TOKEN:選用。要從哪個頁面開始回應,使用先前回應中傳回的頁面權杖。

HTTP 方法和網址:

GET https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/entitlements?filter=FILTER&pageSize=PAGE_SIZE&pageToken=PAGE_TOKEN

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

[
  {
    "name": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID",
    "createTime": "2023-11-21T17:28:39.962144708Z",
    "updateTime": "2023-11-21T17:28:43.160309410Z",
    "eligibleUsers": [
      {
        "principals": [
          "user:alex@example.com"
        ]
      }
    ],
    "approvalWorkflow": {
      "manualApprovals": {
        "steps": [
          {
            "approvers": [
              {
                "principals": [
                  "user:bola@example.com"
                ]
              }
            ],
            "approvalsNeeded": 1
          }
        ]
      }
    },
    "privilegedAccess": {
      "gcpIamAccess": {
        "resourceType": "cloudresourcemanager.googleapis.com/Project",
        "resource": "//cloudresourcemanager.googleapis.com/projects/my-project",
        "roleBindings": [
          {
            "role": "roles/storage.admin"
          }
        ]
      }
    },
    "maxRequestDuration": "14400s",
    "state": "AVAILABLE",
    "requesterJustificationConfig": {
      "unstructured": {}
    },
    "additionalNotificationTargets": {
      "adminEmailRecipients": [
        "alex@example.com"
      ]
    },
    "etag": "00000000000000000000000000000000000000000000000000000000000="
  }
]

取得授權

gcloud

gcloud pam entitlements describe 指令會擷取特定權利。

使用下方的任何指令資料之前,請先替換以下項目:

  • ENTITLEMENT_ID:您要查看詳細資料的授權 ID。
  • RESOURCE_TYPE:選用。權利所屬的資源類型。請使用 organizationfolderproject 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理權限的 Google Cloud專案、資料夾或機構的 ID。專案 ID 為英數字串,例如 my-project。 資料夾和機構 ID 是數字,例如 123456789012

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam entitlements describe \
    ENTITLEMENT_ID \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam entitlements describe `
    ENTITLEMENT_ID `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam entitlements describe ^
    ENTITLEMENT_ID ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

additionalNotificationTargets:
  adminEmailRecipients:
  - alex@example.com
createTime: '2024-03-26T11:07:37.009498890Z'
eligibleUsers:
- principals:
  - user:bola@example.com
etag: 00000000000000000000000000000000000000000000000000000000000=
maxRequestDuration: 3600s
name: projects/my-project/locations/global/entitlements/ENTITLEMENT_ID
privilegedAccess:
  gcpIamAccess:
    resource: //cloudresourcemanager.googleapis.com/projects/my-project
    resourceType: cloudresourcemanager.googleapis.com/Project
    roleBindings:
    - role: roles/storage.admin
requesterJustificationConfig:
  unstructured: {}
state: AVAILABLE
updateTime: '2024-03-26T11:07:40.056780645Z'

REST

Privileged Access Manager API 的 getEntitlement 方法會擷取特定權利。

使用任何要求資料之前,請先替換以下項目:

  • SCOPE:要取得授權的機構、資料夾或專案,格式為 organizations/ORGANIZATION_IDfolders/FOLDER_IDprojects/PROJECT_ID。專案 ID 為英數字串,例如 my-project。資料夾和機構 ID 為數字,例如 123456789012
  • ENTITLEMENT_ID:您要查看詳細資料的授權 ID。

HTTP 方法和網址:

GET https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/entitlements/ENTITLEMENT_ID

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
  "name": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID",
  "createTime": "2023-11-21T17:28:39.962144708Z",
  "updateTime": "2023-11-21T17:28:43.160309410Z",
  "eligibleUsers": [
    {
      "principals": [
        "user:alex@example.com"
      ]
    }
  ],
  "approvalWorkflow": {
    "manualApprovals": {
      "steps": [
        {
          "approvers": [
            {
              "principals": [
                "user:bola@example.com"
              ]
            }
          ],
          "approvalsNeeded": 1
        }
      ]
    }
  },
  "privilegedAccess": {
    "gcpIamAccess": {
      "resourceType": "cloudresourcemanager.googleapis.com/Project",
      "resource": "//cloudresourcemanager.googleapis.com/projects/my-project",
      "roleBindings": [
        {
          "role": "roles/storage.admin"
        }
      ]
    }
  },
  "maxRequestDuration": "14400s",
  "state": "AVAILABLE",
  "requesterJustificationConfig": {
    "unstructured": {}
  },
  "additionalNotificationTargets": {
    "adminEmailRecipients": [
      "alex@example.com"
    ]
  },
  "etag": "00000000000000000000000000000000000000000000000000000000000="
}

使用 gcloud CLI 匯出授權

gcloud pam entitlements export 指令會將特定權利匯出至 YAML 檔案。

使用下方的任何指令資料之前,請先替換以下項目:

  • ENTITLEMENT_ID:要匯出的授權 ID。
  • FILENAME:要將授權內容匯出至的檔案名稱。
  • RESOURCE_TYPE:選用。權利所屬的資源類型。請使用 organizationfolderproject 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理權限的 Google Cloud專案、資料夾或機構的 ID。專案 ID 為英數字串,例如 my-project。 資料夾和機構 ID 是數字,例如 123456789012

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam entitlements export \
    ENTITLEMENT_ID \
    --destination=FILENAME.yaml \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam entitlements export `
    ENTITLEMENT_ID `
    --destination=FILENAME.yaml `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam entitlements export ^
    ENTITLEMENT_ID ^
    --destination=FILENAME.yaml ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

Exported [projects/my-project/locations/global/entitlements/ENTITLEMENT_ID] to 'FILENAME.yaml'.

以程式輔助方式更新授權

更新授權時,請注意下列事項:

  • 更新後的授權設定只會套用至更新後要求的授予項目。不過,核准者變更也會套用至尚未核准或拒絕的現有授權要求。

  • 更新權利時,無法變更是否需要核准。如要變更核准狀態,請改為建立新的授權。

  • 變更權利要求者和核准者可能需要幾分鐘才會生效

gcloud

gcloud pam entitlements update 指令會更新特定權利。

使用下方的任何指令資料之前,請先替換以下項目:

  • ENTITLEMENT_ID:要更新的授權 ID。
  • RESOURCE_TYPE:選用。權利所屬的資源類型。請使用 organizationfolderproject 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理權限的 Google Cloud專案、資料夾或機構的 ID。專案 ID 為英數字串,例如 my-project。 資料夾和機構 ID 是數字,例如 123456789012
  • FILENAME:包含權利修改後設定的檔案。如要建立這個檔案,請取得匯出現有授權,將回應儲存為 YAML 檔案,然後修改該檔案,做為更新要求的本文。您必須在主體中加入 ETAG,才能更新最新版本的授權。如要瞭解可變更或新增的可用欄位,請參閱「 以程式輔助方式建立授權」。

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam entitlements update \
    ENTITLEMENT_ID \
    --entitlement-file=FILENAME.yaml \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam entitlements update `
    ENTITLEMENT_ID `
    --entitlement-file=FILENAME.yaml `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam entitlements update ^
    ENTITLEMENT_ID ^
    --entitlement-file=FILENAME.yaml ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

Request issued for: [ENTITLEMENT_ID]
Waiting for operation [projects/my-project/locations/global/operations/OPERATION_ID] to complete...done.
Updated entitlement [ENTITLEMENT_ID].
approvalWorkflow:
  manualApprovals:
    requireApproverJustification: true
    steps:
    - approvalsNeeded: 1
      approvers:
      - principals:
        - user:alex@example.com
createTime: '2024-04-09T02:39:37.011866832Z'
eligibleUsers:
- principals:
  - user:bola@example.com
etag: 00000000000000000000000000000000000000000000000000000000000=
maxRequestDuration: 7200s
name: projects/my-project/locations/global/entitlements/ENTITLEMENT_ID
privilegedAccess:
  gcpIamAccess:
    resource: //cloudresourcemanager.googleapis.com/projects/my-project
    resourceType: cloudresourcemanager.googleapis.com/Project
    roleBindings:
    - role: roles/storage.admin
requesterJustificationConfig:
  unstructured: {}
state: AVAILABLE
updateTime: '2024-04-09T02:39:40.066770306Z'

REST

Privileged Access Manager API 的 updateEntitlement 方法會更新特定權利。

使用任何要求資料之前,請先替換以下項目:

  • SCOPE:權利所在的機構、資料夾或專案,格式為 organizations/ORGANIZATION_IDfolders/FOLDER_IDprojects/PROJECT_ID。專案 ID 為英數字串,例如 my-project。資料夾和機構 ID 為數字,例如 123456789012
  • ENTITLEMENT_ID:要更新的授權 ID。
  • UPDATED_FIELDS:以逗號分隔的清單,當中列出要更新的授權欄位。例如:

    ?updateMask=privilegedAccess,maxRequestDuration

    如要更新所有可更新的欄位,請將更新遮罩設為 *

  • REQUEST_ID:選用。必須為非零 UUID。 如果伺服器收到含有要求 ID 的要求,會檢查過去 60 分鐘內是否已完成具有該 ID 的其他要求。如果是,系統會忽略新要求。
  • request.json:包含權利修改設定的檔案。如要建立這個檔案,請取得匯出現有授權,將回應儲存為名為 request.json 的檔案,然後修改該檔案,做為更新要求的內文。您必須在主體中加入 ETAG,才能更新最新版本的授權。如要瞭解可變更或新增的可用欄位,請參閱「 以程式輔助方式建立授權」。

HTTP 方法和網址:

PATCH https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/entitlements/ENTITLEMENT_ID?updateMask=UPDATED_FIELDS&requestId=REQUEST_ID

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
  "name": "projects/my-project/locations/global/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.OperationMetadata",
    "createTime": "2024-03-25T01:55:02.544562950Z",
    "target": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID",
    "verb": "update",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

如要查看更新作業的進度,請將 GET 要求傳送至下列端點:

https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/operations/OPERATION_ID

傳送 GET 要求至下列端點,列出所有作業:

https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/operations

以程式輔助方式刪除授權

gcloud

gcloud pam entitlements delete 指令會刪除特定權利。

使用下方的任何指令資料之前,請先替換以下項目:

  • ENTITLEMENT_ID:要刪除的授權 ID。
  • RESOURCE_TYPE:選用。權利所屬的資源類型。請使用 organizationfolderproject 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理權限的 Google Cloud專案、資料夾或機構的 ID。專案 ID 為英數字串,例如 my-project。 資料夾和機構 ID 是數字,例如 123456789012

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam entitlements delete \
    ENTITLEMENT_ID \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam entitlements delete `
    ENTITLEMENT_ID `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam entitlements delete ^
    ENTITLEMENT_ID ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

Delete request issued for: [ENTITLEMENT_ID]
Waiting for operation [projects/my-project/locations/global/operations/OPERATION_ID] to complete...done.
Deleted entitlement [ENTITLEMENT_ID].

REST

Privileged Access Manager API 的 deleteEntitlement 方法會刪除特定權利。

使用任何要求資料之前,請先替換以下項目:

  • SCOPE:要刪除授權的機構、資料夾或專案,格式為 organizations/ORGANIZATION_IDfolders/FOLDER_IDprojects/PROJECT_ID。專案 ID 為英數字串,例如 my-project。資料夾和機構 ID 為數字,例如 123456789012
  • ENTITLEMENT_ID:要刪除的授權 ID。
  • REQUEST_ID:選用。必須為非零 UUID。如果伺服器收到含有要求 ID 的要求,會檢查過去 60 分鐘內是否已完成具有該 ID 的要求。如果是,系統會忽略新要求。

HTTP 方法和網址:

DELETE https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/entitlements/ENTITLEMENT_ID?requestId=REQUEST_ID

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
  "name": "projects/my-project/locations/global/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.OperationMetadata",
    "createTime": "2024-03-06T02:28:28.020293460Z",
    "target": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

如要查看刪除作業的進度,可以將 GET 要求傳送至下列端點:

https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/operations/OPERATION_ID

向下列端點傳送 GET 要求,即可列出所有作業:

https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/operations