이 페이지에서는 IAP(Identity-Aware Proxy)를 사용하여 사용자의 ID를 얻는 방법에 대해 설명합니다. 사용자의 ID를 확인하면 애플리케이션에서 요청이 IAP를 통해 왔는지 확인할 수 있습니다. 앱을 올바르게 보호하려면 항상 아래 메커니즘 중 하나를 사용하여 IAP 인증 사용자 ID를 가져와야 합니다.
서명된 헤더로 사용자 ID 확인
Compute Engine, GKE, Cloud Run, App Engine 표준 환경 또는 App Engine 가변형 환경 앱에 대한 요청이 IAP에서 승인되었는지 확인하려면 앱에서 x-goog-iap-jwt-assertion HTTP 요청 헤더를 확인하여 모든 요청을 검증해야 합니다.
서명된 헤더로 앱 보안에 대해 자세히 알아보세요.
IAP는 또한 사용자 ID를 다음 HTTP 헤더의 백엔드 서비스로 전달합니다. 이러한 헤더에는 네임스페이스 프리픽스 accounts.google.com가 있어야 합니다. 이러한 헤더는 호환성을 위해 제공되지만, 보안 방식으로 사용해서는 안 됩니다. 이러한 헤더를 사용할 때는 위에 나열된 인증된 JWT 헤더의 ID 정보와 비교해야 합니다.
헤더 이름
설명
값 예
X-Goog-Authenticated-User-Email
사용자의 이메일 주소
accounts.google.com:example@gmail.com
X-Goog-Authenticated-User-Id
사용자의 고유 영구 식별자
accounts.google.com:userIDvalue
App Engine 표준 환경 Users API를 사용하여 사용자 ID 확인
다른 방법으로는, App Engine 표준 환경 앱이 있는 경우 Users API가 앱 코드에서 사용자의 ID를 가져오는데 사용될 수 있습니다.
애플리케이션이 이미 이 API를 사용하는 경우 아무것도 변경할 필요가 없습니다.
IAP는 사용자의 ID를 제공하지만 IAP가 사용되면 각 사용자의 Users API 사용자 ID 값이 변경됩니다.
요청에 대한 IAP 인증 사용자 ID를 얻으려면 Users API를 호출하여 현재 사용자를 반환합니다. 함수가 자바에서 req.getUserPrincipal() != null과 같은 사용자를 반환하면 사용자는 IAP에서 인증된 것입니다.
동의 화면
IAP가 사용 설정된 경우 사용자가 앱에 처음 액세스하면 앱에 자신의 ID를 공유할지 확인하기 위한 동의 화면으로 리디렉션됩니다. IAP를 사용 설정하기 전 사용자가 이 앱에 동의를 부여한 경우에도 이 작업은 수행되며, 개발자가 IAP를 사용 중지하고 다시 사용 설정한 경우도 다시 수행됩니다.
Users API를 사용하는 경우 일반적으로 동일한 Google Workspace 도메인 내에 있는 앱 및 사용자의 동의 화면이 표시되지 않습니다. IAP를 사용 설정하면, 동의 화면이 자동으로 숨겨지지 않습니다. IAP가 사용 설정된 상태로 동의 화면을 숨기려면 아래 단계를 따르세요
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eIdentity-Aware Proxy (IAP) allows applications to verify that requests are coming through IAP, requiring validation to ensure proper security.\u003c/p\u003e\n"],["\u003cp\u003eApplications can validate requests via the \u003ccode\u003ex-goog-iap-jwt-assertion\u003c/code\u003e HTTP header, which is the recommended security mechanism for retrieving the user's identity.\u003c/p\u003e\n"],["\u003cp\u003eIAP provides user identity information in the \u003ccode\u003eX-Goog-Authenticated-User-Email\u003c/code\u003e and \u003ccode\u003eX-Goog-Authenticated-User-Id\u003c/code\u003e HTTP headers, but these should only be used for compatibility and must be checked against the JWT header.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine standard environment apps can use the Users API to get the IAP-verified user identity, and enabling IAP changes the user ID values obtained through this API.\u003c/p\u003e\n"],["\u003cp\u003eWhen IAP is enabled, a consent screen will appear for users to confirm sharing their identity, which can be suppressed within a Google Workspace domain by configuring API client access in the Google Admin console.\u003c/p\u003e\n"]]],[],null,["# Getting the user's identity\n\nThis page describes how to get a user's identity with Identity-Aware Proxy\n(IAP). Getting the user's identity enables your application\nto verify that a request came through IAP. To properly\nsecure your app, you must always use one of the mechanisms below to get the\nIAP-authenticated user identity.\n\nGetting the user's identity with signed headers\n-----------------------------------------------\n\nTo make sure a request to your Compute Engine, GKE,\nCloud Run, App Engine standard environment,\nor App Engine flexible environment app was authorized by\nIAP, your app must validate every request by checking the\n`x-goog-iap-jwt-assertion` HTTP request header.\nLearn about [securing your app with signed headers](/iap/docs/signed-headers-howto).\n\nIAP also passes the user's identity to your backend service\nin the following HTTP headers. These headers should have the namespace prefix\n`accounts.google.com`. These headers are available for compatibility,\nbut you shouldn't rely on them as a security mechanism. If you use these\nheaders, you must compare them against the identity information from the\nauthenticated JWT header listed above.\n\nGetting the user's identity with the App Engine standard environment Users API\n------------------------------------------------------------------------------\n\nAlternatively, if you have an App Engine standard environment app, the\n[Users API](/appengine/docs/standard/python/users) can be used to get the\nuser's identity in your app code.\n\nIf your application already uses this API, you don't need to change anything.\nIAP provides the user's identity, but the value for each\nuser's Users API user ID will change when IAP is turned on.\n\nTo get the IAP-verified user identity for a request, call\nthe Users API to return the current\nuser. If the function returns a user, such as `req.getUserPrincipal() != null`\nin Java, the user was authenticated by IAP.\n\nConsent screen\n--------------\n\nWhen IAP is enabled, the first time a user accesses your\napp, they're redirected to a consent screen to confirm that they want to share\ntheir identity with your app. This occurs even if the user granted consent to\nthis app before you enabled IAP, and will occur again if\nyou disable IAP and then re-enable it.\n\nIf you're using the Users API, it normally suppresses the consent screen for\napps and users that are within the same Google Workspace domain. When you enable\nIAP, the consent screen isn't automatically suppressed. To\nsuppress the consent screen with IAP enabled, follow the\nsteps below:\n\n1. Go to your [Google Admin console](http://admin.google.com/). \n [Go to the Admin console](http://admin.google.com/)\n2. On the list of controls, select **Security** .\n 1. If you don't see **Security** listed, select **More controls** from the gray bar at the bottom of the page, then select **Security** from the list of controls.\n 2. If you can't see the controls, make sure you're signed in as an administrator for the domain.\n3. On the list of options, select **Show more** and then **Advanced settings**.\n4. In the **Authentication** section, select **Manage API client access**.\n5. In the **Client Name** field, enter the IAP OAuth 2.0 client ID. You can find the IAP client ID on the [Credentials page](https://console.cloud.google.com/apis/credentials). \n [Go to the IAP credentials page](https://console.cloud.google.com/apis/credentials)\n6. In the **One or More API Scopes** field, enter `email, openid`.\n7. Click **Authorize**.\n\nTo simplify this process, you can use an\n[API call](/iap/docs/reference/compute-engine-apis) to use a single IAP\nOAuth 2.0 client ID for all apps. You can't use the Google Cloud console to\nspecify the client ID to use with IAP.\n\nWhat's next\n-----------\n\n- Learn more about [Identity and Access Management](/iam/docs/overview)."]]