在有主账号成功请求授权并处于有效状态后,具有 privilegedaccessmanager.grants.revoke 权限的主账号可以撤销该授权。处于无效状态的授权无法撤消。
准备工作
确保您已启用 Privileged Access Manager 并为其设置权限。
使用 Google Cloud 控制台撤销授权
如需撤消针对某项使用权做出的特定授权,请按照以下说明操作:
前往 Privileged Access Manager 页面。
选择您要撤消授权的组织、文件夹或项目。
点击授权标签页,然后点击所有用户的授权标签页。 其中包含所有请求者的所有授权、授权状态以及相关的使用权详情。
在表格中,点击您要撤消的授权所在行中的 更多选项。
如需撤消有效授权,请点击撤消授权。
如需撤消针对某项使用权做出的所有有效授权,请完成以下说明:
前往 Privileged Access Manager 页面。
点击使用权标签页,然后点击所有用户的使用权标签页。您可以在此处查找可用的使用权、它们授予的角色以及有效的请求者和审批者。
在表格中,点击您要对其撤消授权的使用权所在行中的 更多选项。
点击撤消所有授权。
以编程方式撤消授权
gcloud
gcloud pam grants revoke 命令可撤消有效的授权。
在使用下面的命令数据之前,请先进行以下替换:
GRANT_ID:您要撤消的授权的 ID。 您可以通过查看授权来检索此 ID。ENTITLEMENT_ID:授权所属的使用权的 ID。REVOKE_REASON:授权被撤消的原因。RESOURCE_TYPE:可选。权利所属的资源类型。使用值organization、folder或project。RESOURCE_ID:与RESOURCE_TYPE一起使用。您要为其管理使用权的 Google Cloud项目、文件夹或组织的 ID。项目 ID 是字母数字字符串,例如my-project。文件夹和组织 ID 是数字,例如123456789012。
执行以下命令:
Linux、macOS 或 Cloud Shell
gcloud pam grants revoke \ GRANT_ID \ --entitlement=ENTITLEMENT_ID \ --reason="REVOKE_REASON" \ --location=global \ --RESOURCE_TYPE=RESOURCE_ID
Windows (PowerShell)
gcloud pam grants revoke ` GRANT_ID ` --entitlement=ENTITLEMENT_ID ` --reason="REVOKE_REASON" ` --location=global ` --RESOURCE_TYPE=RESOURCE_ID
Windows (cmd.exe)
gcloud pam grants revoke ^ GRANT_ID ^ --entitlement=ENTITLEMENT_ID ^ --reason="REVOKE_REASON" ^ --location=global ^ --RESOURCE_TYPE=RESOURCE_ID
您应该会收到类似如下所示的响应:
auditTrail:
accessGrantTime: '2024-04-05T00:29:16.703069535Z'
accessRemoveTime: '2024-04-05T00:29:55.815041079Z'
createTime: '2024-04-05T00:27:43.822053968Z'
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: 2700s
requester: cruz@example.com
state: REVOKED
timeline:
events:
- eventTime: '2024-04-05T00:27:44.014277946Z'
requested:
expireTime: '2024-04-06T00:27:44.014277946Z'
- approved:
actor: alex@example.com
reason: Access allowed under existing policy
eventTime: '2024-04-05T00:29:14.921828714Z'
- eventTime: '2024-04-05T00:29:14.921763008Z'
scheduled:
scheduledActivationTime: '2024-04-05T00:29:14.921763008Z'
- activated: {}
eventTime: '2024-04-05T00:29:16.703069535Z'
- eventTime: '2024-04-05T00:29:55.815041079Z'
revoked:
actor: alex@example.com
reason: Revoking due to new access policy
REST
Privileged Access Manager API 的 revokeGrant 方法可撤消有效的授权。
在使用任何请求数据之前,请先进行以下替换:
SCOPE:权利所属的组织、文件夹或项目,格式为organizations/ORGANIZATION_ID、folders/FOLDER_ID或projects/PROJECT_ID。项目 ID 是字母数字字符串,例如my-project。文件夹和组织 ID 是数字,例如123456789012。ENTITLEMENT_ID:授权所属的使用权的 ID。GRANT_ID:您要撤消的授权的 ID。 您可以通过查看授权来检索此 ID。REVOKE_REASON:撤消授权的原因。
HTTP 方法和网址:
POST https://privilegedaccessmanager.googleapis.com/v1/SCOPE/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_ID:revoke
请求 JSON 正文:
{
"reason": "REVOKE_REASON"
}
如需发送您的请求,请展开以下选项之一:
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/my-project/locations/global/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.OperationMetadata",
"createTime": "2024-03-06T23:07:48.716396505Z",
"target": "projects/my-project/locations/global/entitlements/ENTITLEMENT_ID/grants/GRANT_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