本页介绍了 Cloud de Confiance by S3NS 管理员如何在不配置出站代理的情况下测试组织限制。
如需创建和测试组织限制标头,请执行以下操作:
- 如需获取 Cloud de Confiance by S3NS 组织的组织 ID,请使用 - gcloud organizations list命令:- gcloud organizations list- 以下是输出示例: - DISPLAY_NAME: Organization A ID: 123456789 DIRECTORY_CUSTOMER_ID: a1b2c3d4
- 获取组织 ID 后,请按以下格式为标头值编写 JSON 表示法: - { "resources": ["organizations/123456789"], "options": "strict" }
- 按照 RFC 4648 第 5 节规范对请求标头的值进行编码。 - 例如,如果标头值的 JSON 表示法存储在 - authorized_orgs.json文件中,则以下是通过 basenc 进行编码的结果:- $ OR_HEADER=`cat authorized_orgs.json | basenc --base64url -w0` $ echo $OR_HEADER ewogInJlc291cmNlcyI6IFsib3JnYW5pemF0aW9ucy8xMjM0NTY3ODkiXQogIm9wdGlvbnMiOiAic3RyaWN0Igp9Cgo=
- 如需测试标头配置是否允许访问已获授权的Cloud de Confiance by S3NS 组织中的资源,请针对已获授权的Cloud de Confiance by S3NS 组织中的资源创建 curl 请求。以下是 curl 请求示例: - # Get auth token $ TOKEN=$(gcloud auth print-access-token) # Make a request that includes the organization restriction header; this call makes a request to the logging API for a project within the same organization listed in the header $ curl -H "X-Goog-Allowed-Resources: ${OR_HEADER}" -X POST -d '{"projectIds": ["my-project-123"]}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${TOKEN}" "https://logging.googleapis.com/v2/entries:list" # A successful request returns log entries in this project
- 如需测试标头配置是否会拒绝对授权Cloud de Confiance by S3NS 组织之外的资源的访问权限,请创建一个针对授权Cloud de Confiance by S3NS 组织之外的资源的 curl 请求。以下是 curl 请求示例: - # Get auth token $ TOKEN=$(gcloud auth print-access-token) # Make a request that includes the organization restriction header; this call makes a request to the logging API for a project not within the same organization listed in the header $ curl -H "X-Goog-Allowed-Resources: ${OR_HEADER}" -X POST -d '{"projectIds": ["other-project-123"]}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${TOKEN}" "https://logging.googleapis.com/v2/entries:list" { "error": { "code": 403, "message": "Access denied by organization restriction. Contact your administrator for additional information.", "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "ORG_RESTRICTION_VIOLATION", "domain": "googleapis.com", "metadata": { "service": "logging.googleapis.com", "consumer": "other-project-123" } } ] } }- “访问权限被拒”错误消息表示系统拒绝了对资源的请求。