이 페이지에서는 Google Cloud 관리자가 이그레스 프록시를 구성하지 않고도 조직 액세스 제한을 테스트하는 방법을 설명합니다.
조직 액세스 제한 헤더를 만들고 테스트하려면 다음 안내를 따르세요.
조직의 Google Cloud 조직 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=
헤더 구성이 승인된 Google Cloud 조직 내의 리소스에 액세스를 허용할지 여부를 테스트하려면 승인된 Google Cloud 조직 내의 리소스에 대한 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
헤더 구성이 승인된 Google Cloud 조직 외부의 리소스에 대한 액세스를 거부하는지 테스트하려면 승인된 Google Cloud 조직 외부의 리소스에 대한 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" } } ] } }
액세스 거부 오류 메시지는 리소스에 대한 요청이 거부되었음을 나타냅니다.
다음 단계
- 조직 액세스 제한 사용 알아보기
- 조직 액세스 제한에서 지원하는 서비스 알아보기