在 Privileged Access Manager 中查看授權

您可以查看授權的狀態和記錄,或撤銷其他主體的有效授權。補助結束後,補助記錄會保留 30 天。

事前準備

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

使用 Google Cloud 控制台查看授予項目

如要查看補助金,請完成下列操作:

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

    前往 Privileged Access Manager

  2. 選取要查看補助金的機構、資料夾或專案。

  3. 依序點按「授予項目」分頁標籤和「所有使用者的授予項目」分頁標籤。這個分頁包含所有授權、授權要求者和授權狀態。補助金可能處於下列狀態:

    狀態 說明
    啟用中 正在啟用補助金。
    啟用失敗 發生無法重試的錯誤,因此 Privileged Access Manager 無法授予角色。
    有效 授權有效,且主體可存取角色允許的資源。
    等待核准 授予要求正在等待核准者做出決定。
    已拒絕 核准者已拒絕授權要求。
    已結束 授權已終止,且主體已移除角色。
    已過期 由於未在 24 小時內核准,授權要求已過期。
    已撤銷 授權遭撤銷,主體無法再存取角色允許的資源。
    正在撤銷 系統正在撤銷授予項目。

    狀態標籤

    除了上述狀態,補助金狀態旁還會顯示下列狀態標籤,表示特殊情況:

    透過 IAM 修改

    與這項授權相關聯的 IAM 政策繫結,已透過 IAM 直接修改。如要查看已修改的繫結詳細資料,請前往Google Cloud 控制台的「IAM」頁面。當修改後的授權遭到撤銷或終止時,Privileged Access Manager 只會移除其建立但未透過 IAM 修改的繫結。

    修改 IAM 條件標題或運算式,或是移除要求者對已授予角色的存取權,都視為外部修改。新增或修改 IAM 條件說明不屬於外部修改。

    Privileged Access Manager 每 5 分鐘會檢查授權是否有外部修改。這些變更最多可能需要 5 分鐘才會生效。如果在這 5 分鐘內進行變更,然後又還原,Privileged Access Manager 可能不會偵測到。

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

    • 如要查看補助金詳細資料 (包括記錄),請按一下「查看詳細資料」。 您也可以透過這個面板撤銷授權。

    • 如要撤銷有效授權,請按一下「撤銷授權」

您也可以在 Google Cloud 控制台的 IAM 頁面中,查看暫時授予的角色。在「按照主體查看」分頁中,暫時授予的角色會顯示「Created by: PAM」(由 PAM 建立) 條件。

以程式輔助方式查看授權

如要透過程式查看補助,可以搜尋、列出及取得補助。

搜尋補助金

gcloud

The gcloud pam grants search 指令會搜尋您建立的授權,並可核准或拒絕,或是已核准或拒絕。使用這個方法時,不需要特定的 Privileged Access Manager 權限。

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

  • ENTITLEMENT_ID:授權所屬的授權 ID。您可以 查看權利來擷取 ID。
  • CALLER_RELATIONSHIP_TYPE:請使用下列其中一個值:

    • had-created:傳回呼叫端建立的授權。
    • had-approved:傳回呼叫端已核准或拒絕的授權。
    • can-approve:傳回呼叫端可核准或拒絕的授權。
  • RESOURCE_TYPE:選用。權利所屬的資源類型。請使用 organizationfolderproject 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理權限的 Google Cloud專案、資料夾或機構的 ID。專案 ID 為英數字串,例如 my-project。 資料夾和機構 ID 是數字,例如 123456789012

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam grants search \
    --entitlement=ENTITLEMENT_ID \
    --caller-relationship=CALLER_RELATIONSHIP_TYPE \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam grants search `
    --entitlement=ENTITLEMENT_ID `
    --caller-relationship=CALLER_RELATIONSHIP_TYPE `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam grants search ^
    --entitlement=ENTITLEMENT_ID ^
    --caller-relationship=CALLER_RELATIONSHIP_TYPE ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

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

additionalEmailRecipients:
- bola@example.com
createTime: '2024-03-07T00:34:32.557017289Z'
justification:
  unstructuredJustification: Renaming a file to mitigate issue #312
name: projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID
privilegedAccess:
  gcpIamAccess:
    resource: //cloudresourcemanager.googleapis.com/projects/my-project
    resourceType: cloudresourcemanager.googleapis.com/Project
    roleBindings:
    - role: roles/storage.admin
requestedDuration: 3600s
requester: cruz@example.com
state: DENIED
timeline:
  events:
  - eventTime: '2024-03-07T00:34:32.793769042Z'
    requested:
      expireTime: '2024-03-08T00:34:32.793769042Z'
  - denied:
      actor: alex@example.com
      reason: Issue has already been resolved
    eventTime: '2024-03-07T00:36:08.309116203Z'
updateTime: '2024-03-07T00:34:32.926967128Z'

REST

Privileged Access Manager API 的 searchGrants 方法會搜尋您建立、可核准或拒絕,或已核准或拒絕的授權。使用這個方法時,不需要特定的 Privileged Access Manager 權限。

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

  • SCOPE:權利所在的機構、資料夾或專案,格式為 organizations/ORGANIZATION_IDfolders/FOLDER_IDprojects/PROJECT_ID。專案 ID 為英數字串,例如 my-project。資料夾和機構 ID 為數字,例如 123456789012
  • ENTITLEMENT_ID:授權所屬的授權 ID。您可以 查看權利來擷取 ID。
  • RELATIONSHIP_TYPE:有效值如下:
    • HAD_CREATED:傳回呼叫端建立的授權。
    • HAD_APPROVED:傳回呼叫端先前核准或拒絕的授權。
    • CAN_APPROVE:傳回呼叫端可核准或拒絕的授權。
  • FILTER:選用。傳回欄位值符合 AIP-160 運算式的授權。
  • PAGE_SIZE:選用。要在回應中傳回的項目數。
  • PAGE_TOKEN:選用。要從哪個頁面開始回應,使用先前回應中傳回的頁面權杖。

HTTP 方法和網址:

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

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

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

{
  "grants": [
    {
      "name": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID",
      "createTime": "2024-03-06T03:08:49.330577625Z",
      "updateTime": "2024-03-06T03:08:49.625874598Z",
      "requester": "alex@example.com",
      "requestedDuration": "3600s",
      "justification": {
        "unstructuredJustification": "Emergency service for outage"
      },
      "state": "APPROVAL_AWAITED",
      "timeline": {
        "events": [
          {
            "eventTime": "2024-03-06T03:08:49.462765846Z",
            "requested": {
              "expireTime": "2024-03-07T03:08:49.462765846Z"
            }
          }
        ]
      },
      "privilegedAccess": {
        "gcpIamAccess": {
          "resourceType": "cloudresourcemanager.googleapis.com/Project",
          "resource": "//cloudresourcemanager.googleapis.com/projects/my-project",
          "roleBindings": [
            {
              "role": "roles/storage.admin"
            }
          ]
        }
      },
      "additionalEmailRecipients": [
        "bola@google.com"
      ]
    }
  ]
}

列出授權

gcloud

gcloud pam grants list 指令會列出屬於特定授權的授權。

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

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

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam grants list \
    --entitlement=ENTITLEMENT_ID \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam grants list `
    --entitlement=ENTITLEMENT_ID `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam grants list ^
    --entitlement=ENTITLEMENT_ID ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

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

createTime: '2024-03-25T23:10:16.952789492Z'
justification:
  unstructuredJustification: Adding missing file for service to work properly
name: projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID
privilegedAccess:
  gcpIamAccess:
    resource: //cloudresourcemanager.googleapis.com/projects/my-project
    resourceType: cloudresourcemanager.googleapis.com/Project
    roleBindings:
    - role: roles/storage.admin
requestedDuration: 1800s
requester: alex@example.com
state: EXPIRED
timeline:
  events:
  - eventTime: '2024-03-25T23:10:17.155612987Z'
    requested:
      expireTime: '2024-03-26T23:10:17.155612987Z'
  - eventTime: '2024-03-26T23:10:17.279777370Z'
    expired: {}
updateTime: '2024-03-25T23:10:17.273416257Z'

REST

Privileged Access Manager API 的 listGrants 方法會列出屬於特定權限的授權。

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

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

HTTP 方法和網址:

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

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

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

{
  "grants": [
    {
      "name": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID",
      "createTime": "2024-03-06T03:08:49.330577625Z",
      "updateTime": "2024-03-06T03:08:49.625874598Z",
      "requester": "alex@example.com",
      "requestedDuration": "3600s",
      "justification": {
        "unstructuredJustification": "Emergency service for outage"
      },
      "state": "APPROVAL_AWAITED",
      "timeline": {
        "events": [
          {
            "eventTime": "2024-03-06T03:08:49.462765846Z",
            "requested": {
              "expireTime": "2024-03-07T03:08:49.462765846Z"
            }
          }
        ]
      },
      "privilegedAccess": {
        "gcpIamAccess": {
          "resourceType": "cloudresourcemanager.googleapis.com/Project",
          "resource": "//cloudresourcemanager.googleapis.com/projects/my-project",
          "roleBindings": [
            {
              "role": "roles/storage.admin"
            }
          ]
        }
      },
      "additionalEmailRecipients": [
        "bola@google.com"
      ]
    }
  ]
}

取得補助

gcloud

gcloud pam grants describe 指令會擷取特定授權。

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

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

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud pam grants describe \
    GRANT_ID \
    --entitlement=ENTITLEMENT_ID \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud pam grants describe `
    GRANT_ID `
    --entitlement=ENTITLEMENT_ID `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud pam grants describe ^
    GRANT_ID ^
    --entitlement=ENTITLEMENT_ID ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID

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

createTime: '2024-03-25T23:10:16.952789492Z'
justification:
  unstructuredJustification: Adding missing file for service to work properly
name: projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID
privilegedAccess:
  gcpIamAccess:
    resource: //cloudresourcemanager.googleapis.com/projects/my-project
    resourceType: cloudresourcemanager.googleapis.com/Project
    roleBindings:
    - role: roles/storage.admin
requestedDuration: 1800s
requester: alex@example.com
state: EXPIRED
timeline:
  events:
  - eventTime: '2024-03-25T23:10:17.155612987Z'
    requested:
      expireTime: '2024-03-26T23:10:17.155612987Z'
  - eventTime: '2024-03-26T23:10:17.279777370Z'
    expired: {}
updateTime: '2024-03-25T23:10:17.273416257Z'

REST

Privileged Access Manager API 的 getGrant 方法會擷取特定授權。

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

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

HTTP 方法和網址:

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

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

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

{
  "name": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID",
  "createTime": "2024-03-06T03:08:49.330577625Z",
  "updateTime": "2024-03-06T03:08:49.625874598Z",
  "requester": "alex@example.com",
  "requestedDuration": "3600s",
  "justification": {
    "unstructuredJustification": "Emergency service for outage"
  },
  "state": "APPROVAL_AWAITED",
  "timeline": {
    "events": [
      {
        "eventTime": "2024-03-06T03:08:49.462765846Z",
        "requested": {
          "expireTime": "2024-03-07T03:08:49.462765846Z"
        }
      }
    ]
  },
  "privilegedAccess": {
    "gcpIamAccess": {
      "resourceType": "cloudresourcemanager.googleapis.com/Project",
      "resource": "//cloudresourcemanager.googleapis.com/projects/my-project",
      "roleBindings": [
        {
          "role": "roles/storage.admin"
        }
      ]
    }
  },
  "additionalEmailRecipients": [
    "bola@google.com"
  ]
}