This page walks you through deploying a Google App Engine standard or flexible environment application and securing it with Cloud Identity-Aware Proxy (Cloud IAP). The quickstart includes sample code for an App Engine standard environment webapp that verifies a logged-in user's name. This quickstart uses Cloud Shell to clone and deploy the sample application. You can use this quickstart to enable Cloud IAP for your own App Engine standard environment or App Engine flexible environment Beta app.
Before you begin
Sign in to your Google account.
If you don't already have one, sign up for a new account.
- Select or create a Cloud Platform project.
- Enable billing for your project.
Starting Cloud Shell
Click Activate Google Cloud Shell at the top of the
A Cloud Shell session opens inside a new frame at the bottom of the console and displays a command-line prompt. It can take a few seconds for the shell session to be initialized.
Enter the following in Cloud Shell to display the project IDs for your
gcloud projects list
Run the following command to set the default project, where
YOUR-PROJECT-IDis the project ID you want to use for this quickstart:
gcloud config set project YOUR-PROJECT-ID
Getting the sample code
Enter the following command in Cloud Shell to get the sample application:
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
Change to the directory that contains the sample code:
Deploying the application
gcloudto deploy the application to App Engine:
gcloud app deploy
target url:is displayed in the format
https://YOUR_PROJECT_ID.appspot.com. To access your application, navigate to that URL in your web brower.
Enabling Cloud IAP
Go to the
Cloud IAP admin page.
Go to the Cloud IAP admin page
- If you don't already have an active project, you'll be prompted to select the project you want to secure with Cloud IAP. Select the project to which you deployed the sample application.
If you haven't configured your project's OAuth consent screen, you'll be
prompted to do so:
Go to the OAuth consent screen.
Configure consent screen
- Under Email address, select the email address you want to display as a public contact. This must be your email address, or a Google Group you own.
- Enter the Product name you want to display.
- Add any optional details you'd like.
- Click Save.
Go back to the Cloud IAP admin page.
Go to the Cloud IAP admin page
- Go to the OAuth consent screen.
On the Identity-Aware Proxy page, under
Access, click Add to add members to the
project. These members will be assigned the
IAP access: HTTPSrole on the current project, and will be able to access all of the project's Cloud IAP-secured resources.
Members can be:
- Google Accounts: email@example.com
- Google Groups: firstname.lastname@example.org
- Service accounts: email@example.com
- G Suite domains: example.com
- Under Resources, find the App Engine app you want to restrict access to. The Published column shows the URL of the app. To turn on Cloud IAP for the app, click Off in the IAP column.
In the Turn on IAP window that appears, list all domains
used to access the resource.
Verify that the automatically added domain matches the
appspot.comdomain where you expect to serve your application.
Make sure to list non-default App Engine versions like
test.app_name.appspot.comif you want to use them to access the app.
- Verify that the automatically added domain matches the
To confirm that you want the application to be secured by
Cloud IAP, click Turn On. After you turn it
on, Cloud IAP requires login credentials for all connections to
your application, and only accounts with the
IAP access: HTTPSrole on this project will be given access.
Access the app URL from the Google account that you added to Cloud IAP. You should have unrestricted access to the app.
Next, use an incognito window in Chrome to access the app and sign in when prompted. If you try to access the app with an account that isn't authorized, you'll see a You don't have access message.