이 문서에서는 IAP (Identity-Aware Proxy)의 OAuth 구성을 맞춤설정하는 시기와 방법을 설명합니다.
IAP는 Google 관리 OAuth 클라이언트를 사용하여 사용자를 인증합니다.
Google 관리 OAuth 클라이언트는 브라우저를 통해 IAP가 사용 설정된 애플리케이션에 액세스할 때 동일한 조직 내의 사용자로 액세스를 제한합니다.
커스텀 OAuth 구성을 사용해야 하는 경우
다음을 수행하려면 커스텀 OAuth 구성을 사용해야 합니다.
- 조직 외부의 사용자가 IAP가 사용 설정된 애플리케이션에 액세스하도록 허용합니다.
- 인증 중 자체 브랜드 정보를 표시합니다.
- 애플리케이션에 프로그래매틱 액세스를 사용 설정합니다.
OAuth 구성을 맞춤설정할 때는 OAuth 동의 화면을 구성해야 합니다. 이렇게 하려면 애플리케이션의 브랜딩 정보가 Google 인증 절차를 거쳐야 합니다. 인증 프로세스에 관한 자세한 내용은 OAuth 동의 화면 설정을 참고하세요.
맞춤 OAuth 클라이언트의 사용자 인증 정보를 만들고 관리하는 것은 개발자의 책임입니다. 여기에는 클라이언트 보안 비밀번호를 안전하게 저장하고 필요한 경우 승인된 사용자와 공유하는 것이 포함됩니다.
Google 관리 OAuth 클라이언트 및 커스텀 OAuth 클라이언트 비교
Google 관리 OAuth 클라이언트는 프로그래매틱 방식으로 IAP 보호 애플리케이션에 액세스할 수 없습니다. 하지만 Google 관리 OAuth 클라이언트를 사용하는 IAP 보호 애플리케이션은 programmatic_clients
설정 또는 서비스 계정 JWT를 통해 구성된 별도의 OAuth 클라이언트를 사용하여 프로그래매틱 방식으로 계속 액세스할 수 있습니다.
다음 표에서는 Google 관리 OAuth 클라이언트와 맞춤 OAuth 클라이언트를 비교합니다.
Google 관리 OAuth 클라이언트 | 맞춤 OAuth 클라이언트 | |
---|---|---|
사용자 | 내부 전용 | 내부 및 외부용 |
브랜드 | Google Cloud 브랜드 | 고객 소유 브랜드 |
OAuth 구성 | Google 구성됨 | 고객이 구성함 |
OAuth 사용자 인증 정보 | Google 관리 | 고객 관리 |
애플리케이션 액세스 | 브라우저 흐름만 | 브라우저 흐름 및 프로그래매틱 액세스 |
맞춤 OAuth 클라이언트 구성을 사용하여 IAP 사용 설정
다음 섹션에서는 여러 리소스에 맞는 맞춤 OAuth 클라이언트 구성을 사용하여 IAP를 사용 설정하는 방법을 설명합니다.
App Engine
콘솔
If you haven't configured your project's OAuth consent screen, you'll be prompted to do so. To configure your OAuth consent screen, see Setting up your OAuth consent screen.
Setting up IAP access
-
Go to the
Identity-Aware Proxy page.
Go to the Identity-Aware Proxy page - Select the project you want to secure with IAP.
- Select the checkbox next to the resource you want to grant access to.
- On the right side panel, click Add principal.
-
In the Add principals dialog that appears, enter the email addresses of groups or
individuals who should have the IAP-secured Web App User role for the project.
The following kinds of principals can have this role:
- Google Account: user@gmail.com
- Google Group: admins@googlegroups.com
- Service account: server@example.gserviceaccount.com
- Google Workspace domain: example.com
Make sure to add a Google Account that you have access to.
- Select Cloud IAP > IAP-secured Web App User from the Roles drop-down list.
- Click Save.
Turning on IAP
-
On the Identity-Aware Proxy page, under APPLICATIONS,
find the application you want to restrict
access to. To turn on IAP for a resource,
- In the Turn on IAP window that appears, click Turn On to confirm that you want IAP to secure your resource. After you turn on IAP, it requires login credentials for all connections to your load balancer. Only accounts with the IAP-Secured Web App User role on the project will be given access.
gcloud
프로젝트와 IAP를 설정하려면 최신 버전의 gcloud CLI가 필요합니다. gcloud CLI 설치 방법에 대한 자세한 내용은 gcloud CLI 설치를 참조하세요.
-
인증하려면 Google Cloud CLI를 사용하고 다음 명령어를 실행합니다.
gcloud auth login
- 로그인하려면 표시되는 URL을 따릅니다.
- 로그인한 후에는 표시된 확인 코드를 복사하고 이를 명령줄에 붙여넣습니다.
-
다음 명령어를 실행하여 IAP로 보호하려는 리소스가 포함된 프로젝트를 지정합니다.
gcloud config set project PROJECT_ID
- IAP용 OAuth 클라이언트 만들기의 안내에 따라 OAuth 동의 화면을 구성하고 OAuth 클라이언트를 만듭니다.
- OAuth 클라이언트 ID 및 보안 비밀을 저장합니다.
-
IAP를 사용 설정하려면 다음 명령어를 실행하세요.
gcloud iap web enable \ --oauth2-client-id=CLIENT_ID \ --oauth2-client-secret=CLIENT_SECRET \ --resource-type=app-engine
IAP를 사용 설정한 후 gcloud CLI를 사용하여 IAM 역할 roles/iap.httpsResourceAccessor
를 사용하여 IAP 액세스 정책을 수정할 수 있습니다. 역할 및 권한 관리에 대해 자세히 알아보세요.
API
Follow the instructions in Creating OAuth clients for IAP to configure the OAuth consent screen and create the OAuth client.
Save the OAuth client ID and secret.
Run the following command to prepare a
settings.json
file.cat << EOF > settings.json { "iap": { "enabled": true, "oauth2ClientId": "CLIENT_ID", "oauth2ClientSecret":" CLIENT_SECRET" } } EOF
Run the following command to enable IAP.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d @settings.json \ "https://appengine.googleapis.com/v1/apps/PROJECT_ID?updateMask=iap"
After you enable IAP, you can use the Google Cloud CLI to modify the
IAP access policy using the IAM role
roles/iap.httpsResourceAccessor
. Learn more about
managing roles and permissions.
Compute Engine
콘솔
프로젝트의 OAuth 동의 화면을 구성하지 않았으면, 구성하라는 메시지가 표시됩니다. OAuth 동의 화면을 구성하려면 OAuth 동의 화면 설정을 참조하세요.
IAP 액세스 설정
-
Identity-Aware Proxy 페이지로 이동합니다.
IAP(Identity-Aware Proxy) 페이지로 이동 - IAP로 보호하려는 프로젝트를 선택합니다.
-
액세스 권한을 부여할 리소스 옆에 있는 체크박스를 선택합니다.
리소스가 표시되지 않으면 리소스가 생성되었고 BackendConfig Compute Engine 인그레스 컨트롤러가 동기화되었는지 확인합니다.
백엔드 서비스를 사용할 수 있는지 확인하려면 다음 gcloud 명령어를 실행합니다.
gcloud compute backend-services list
- 오른쪽 패널에서 주 구성원 추가를 클릭합니다.
-
표시된 주 구성원 추가 대화상자에서 프로젝트에 대한 IAP 보안 웹 앱 사용자 역할이 있어야 하는 그룹 또는 개별 사용자의 이메일 주소를 입력합니다.
다음과 같은 종류의 주 구성원이 이 역할을 가질 수 있습니다.
- Google 계정: user@gmail.com
- Google Groups: admins@googlegroups.com
- 서비스 계정: server@example.gserviceaccount.com
- Google Workspace 도메인: example.com
액세스 권한이 있는 Google 계정을 추가해야 합니다.
- 역할 드롭다운 목록에서 Cloud IAP > IAP 보안 웹 앱 사용자를 선택합니다.
- 저장을 클릭합니다.
gcloud
프로젝트와 IAP를 설정하려면 최신 버전의 gcloud CLI가 필요합니다. gcloud CLI 설치 방법에 대한 자세한 내용은 gcloud CLI 설치를 참조하세요.
-
인증하려면 Google Cloud CLI를 사용하고 다음 명령어를 실행합니다.
gcloud auth login
- 로그인하려면 표시되는 URL을 따릅니다.
- 로그인한 후에는 표시된 확인 코드를 복사하고 이를 명령줄에 붙여넣습니다.
-
다음 명령어를 실행하여 IAP로 보호하려는 리소스가 포함된 프로젝트를 지정합니다.
gcloud config set project PROJECT_ID
- IAP용 OAuth 클라이언트 만들기의 안내에 따라 OAuth 동의 화면을 구성하고 OAuth 클라이언트를 만듭니다.
- OAuth 클라이언트 ID 및 보안 비밀을 저장합니다.
-
IAP를 사용 설정하려면 전역 또는 리전 범위 명령어를 실행합니다.
전역 범위 리전 범위gcloud compute backend-services update BACKEND_SERVICE_NAME \ --global \ --iap=enabled,oauth2-client-id=CLIENT_ID,oauth2-client-secret=CLIENT_SECRET
gcloud compute backend-services update BACKEND_SERVICE_NAME \ --region REGION_NAME \ --iap=enabled,oauth2-client-id=CLIENT_ID,oauth2-client-secret=CLIENT_SECRET
IAP를 사용 설정한 후 gcloud CLI를 사용하여 IAM 역할 roles/iap.httpsResourceAccessor
를 사용하여 IAP 액세스 정책을 수정할 수 있습니다. 역할 및 권한 관리에 대해 자세히 알아보세요.
API
Follow the instructions in Creating OAuth clients for IAP to configure the OAuth consent screen and create the OAuth client.
Save the OAuth client ID and secret.
Run the following command to prepare a
settings.json
file.cat << EOF > settings.json { "iap": { "enabled": true, "oauth2ClientId": "CLIENT_ID", "oauth2ClientSecret": "CLIENT_SECRET" } } EOF
Run the following command to enable IAP.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d @settings.json \ "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/REGION/backendServices/BACKEND_SERVICE_NAME"
After you enable IAP, you can use the gcloud CLI to modify the
IAP access policy using the IAM role
roles/iap.httpsResourceAccessor
. Learn more about
managing roles and permissions.
Cloud Run
콘솔
If you haven't configured your project's OAuth consent screen, you're prompted to do so. To configure your OAuth consent screen, see Setting up your OAuth consent screen
Setting up IAP access
- Open the Identity-Aware Proxy page.
Go to Identity-Aware Proxy - Select the project you want to secure with IAP.
- Under Applications, select the checkbox next to the load balancer backend service to which you want to add members.
- On the right side panel, click Add member.
In the Add members dialog, enter the accounts of groups or individuals who should have the IAP-secured Web App User role for the project. The following kinds of accounts can be members:
- Google Account: user@gmail.com - This can also be a Google Workspace account, such as user@google.com or some other Google Workspace domain.
- Google Group: admins@googlegroups.com
- Service account: server@example.gserviceaccount.com
- Google Workspace domain: example.com
Select Cloud IAP > IAP-secured Web App User from the Roles list.
Click Save.
Turning on IAP
- On the IAP page, under Applications, find the load balancer backend service to which you want to restrict access. Click the IAP toggle to enable IAP on a resource.
- In the Turn on IAP window that appears, click Turn On to confirm that you want IAP to secure your resource. After you turn on IAP, it requires login credentials for all connections to your load balancer. Only accounts with the IAP-Secured Web App User role on the project will be given access.
To authorize IAP to send traffic to the backend Cloud Run service, follow the instructions at Add principals to a service to add the following principle and role.
- Principal:
service-[PROJECT-NUMBER]@gcp-sa-iap.iam.gserviceaccount.com
- Role: Cloud Run Invoker
- Principal:
gcloud
- IAP용 OAuth 클라이언트 만들기의 안내에 따라 OAuth 동의 화면을 구성하고 OAuth 클라이언트를 만듭니다.
- OAuth 클라이언트 ID 및 보안 비밀을 저장합니다.
- 아직 서비스 계정을 만들지 않았다면 다음 명령어를 실행하여 서비스 계정을 만듭니다. 이전에 서비스 계정을 만든 경우 명령어를 실행해도 중복 서비스 계정이 생성되지 않습니다.
gcloud beta services identity create \ --service=iap.googleapis.com --project=PROJECT_ID
- 다음 명령어를 실행하여 이전 단계에서 만든 서비스 계정에 호출자 권한을 부여합니다.
gcloud run services add-iam-policy-binding SERVICE-NAME \ --member='serviceAccount:service-PROJECT-NUMBER@gcp-sa-iap.iam.gserviceaccount.com' \ --role='roles/run.invoker'
부하 분산기 백엔드 서비스가 전역인지 리전인지에 따라 전역 또는 리전 범위 명령어를 실행하여 IAP를 사용 설정합니다. 이전 단계의 OAuth 클라이언트 ID 및 보안 비밀을 사용합니다.
전역 범위
gcloud compute backend-services update BACKEND_SERVICE_NAME \ --global \ --iap=enabled,oauth2-client-id=CLIENT_ID,oauth2-client-secret=CLIENT_SECRET
리전 범위
다음을 바꿉니다.gcloud compute backend-services update BACKEND_SERVICE_NAME \ --region REGION_NAME \ --iap=enabled,oauth2-client-id=CLIENT_ID,oauth2-client-secret=CLIENT_SECRET
- BACKEND_SERVICE_NAME: 백엔드 서비스의 이름입니다.
- CLIENT_ID: 이전 단계의 OAuth 클라이언트 ID입니다.
- CLIENT_SECRET: 이전 단계의 OAuth 클라이언트 보안 비밀번호입니다.
- REGION_NAME: IAP를 사용 설정할 리전입니다.
IAP를 사용 설정한 후 Google Cloud CLI를 사용하여 Identity and Access Management 역할 roles/iap.httpsResourceAccessor
로 IAP 액세스 정책을 수정할 수 있습니다. 자세한 내용은 역할 및 권한 관리를 참조하세요.
Google Kubernetes Engine
콘솔
프로젝트의 OAuth 동의 화면을 구성하지 않았으면, 구성하라는 메시지가 표시됩니다. OAuth 동의 화면을 구성하려면 OAuth 동의 화면 설정을 참조하세요.
IAP 액세스 설정
-
Identity-Aware Proxy 페이지로 이동합니다.
IAP(Identity-Aware Proxy) 페이지로 이동 - IAP로 보호하려는 프로젝트를 선택합니다.
-
액세스 권한을 부여할 리소스 옆에 있는 체크박스를 선택합니다.
리소스가 표시되지 않으면 리소스가 생성되었고 BackendConfig Compute Engine 인그레스 컨트롤러가 동기화되었는지 확인합니다.
백엔드 서비스를 사용할 수 있는지 확인하려면 다음 gcloud 명령어를 실행합니다.
gcloud compute backend-services list
- 오른쪽 패널에서 주 구성원 추가를 클릭합니다.
-
표시된 주 구성원 추가 대화상자에서 프로젝트에 대한 IAP 보안 웹 앱 사용자 역할이 있어야 하는 그룹 또는 개별 사용자의 이메일 주소를 입력합니다.
다음과 같은 종류의 주 구성원이 이 역할을 가질 수 있습니다.
- Google 계정: user@gmail.com
- Google Groups: admins@googlegroups.com
- 서비스 계정: server@example.gserviceaccount.com
- Google Workspace 도메인: example.com
액세스 권한이 있는 Google 계정을 추가해야 합니다.
- 역할 드롭다운 목록에서 Cloud IAP > IAP 보안 웹 앱 사용자를 선택합니다.
- 저장을 클릭합니다.
GKE
Configure the BackendConfig
If you are running GKE clusters version 1.24 or later, you can configure IAP and GKE by using the Kubernetes Gateway API. See Configure IAP for instructions.
Follow the instructions in Creating OAuth clients for IAP to configure the OAuth consent screen and create the OAuth client.
Create a Kubernetes Secret to wrap the OAuth client.
Replace the following:kubectl create secret generic MY_SECRET --from-literal=client_id=CLIENT_ID \ --from-literal=client_secret=CLIENT_SECRET
MY_SECRET
: The name of the secret to createCLIENT_ID
: The OAuth client IDCLIENT_SECRET
: The OAuth client secret
You should receive confirmation, like the following output, that the Secret was successfully created:
secret "MY_SECRET" created
Add the OAuth credentials to the BackendConfig.
apiVersion: cloud.google.com/v1 kind: BackendConfig metadata: name: CONFIG_DEFAULT namespace: my-namespace spec: iap: enabled: true oauthclientCredentials: secretName: MY_SECRET
Enable IAP by associating Service ports with your BackendConfig. See Associating BackendConfig with your Ingress. One way to make this association is to make all ports for the service default to your BackendConfig, which you can do by adding the following annotation to your Service resource:
metadata: annotations: beta.cloud.google.com/backend-config: '{"default": "CONFIG_DEFAULT"}}'
After you enable IAP, you can use the gcloud CLI to modify the
IAP access policy using the IAM role
roles/iap.httpsResourceAccessor
. Learn more about
managing roles and permissions.
Troubleshooting
If the secretName
you referenced doesn't exist or isn't structured
properly, one of the following error messages will display:
BackendConfig default/config-default is not valid: error retrieving secret "foo": secrets "foo" not found.
To resolve this error, make sure that you've created the Kubernetes Secret correctly as described in step 2.BackendConfig default/config-default is not valid: secret "foo" missing client_secret data.
To resolve this error, make sure that you've created the OAuth credentials correctly. Also, make sure that you referenced the correctclient_id
andclient_secret
keys.