Stay organized with collections Save and categorize content based on your preferences.
This guide describes how to extend Identity-Aware Proxy (IAP) access policies using access levels and the Identity and Access Management (IAM) Conditions Framework. Access levels allow access restrictions to resources based on IP address and end-user device attributes. IAM conditions allow access restrictions based on URL hosts, paths, date, and time.
For example, depending on the policy configuration, your sensitive app can:
/admin
.Before you begin, you'll need the following:
To limit access based on IP address or end-user device attributes, you need to create an access level. To learn how to create an access level, see the Access Context Manager guide. IAP uses the access level name to associate it with a IAP-secured app.
The use of scoped policies is not supported by IAP. Access levels must be set in the organizational access policy. For more information, see Create an access policy.
Editing the IAM policyA IAP-secured app has an IAM policy that binds the IAP role to the app.
By adding an IAM conditional binding to the IAM policy, access to your resources are further restricted based on request attributes. These request attributes include:
Note that request values being compared to request.host
and request.path
specified in an IAM conditional binding must be exact. For example, if you restrict access to paths starting with /internal admin
, one can bypass the restriction by going to /internal%20admin
. For more information about hostname and path conditions, see Using hostname and path conditions.
Add and edit conditional bindings on your IAM policy by following the process below.
ConsoleTo add a conditional binding using the Google Cloud console:
Go to the IAP admin page.
Select the checkbox next to the resources that you want to update IAM permissions for.
On the right side Info panel, click Add principal.
In the New principal box, enter the principals that you want to assign a role to.
In the Select a role drop-down list, select the IAP-secured Web App User role and specify access level conditions that the principals will need to meet to access the resource.
If you want to add more roles to the principals, click Add another role.
When you're finished adding roles, click Save.
You have now added a conditional binding to your resource.
To remove a conditional binding:
Go to the IAP admin page.
Select the checkbox next to the resource that you want to remove a principal's IAM role from.
On the right side Info panel, under Role / Principal, click the role that you want to remove from the principal.
Click Remove next to the principal.
On the Remove role from principal dialog that appears, click Remove. To remove all non-inherited roles from the principal on the selected resource, select the checkbox before clicking Remove.
At this time, you can only use the gcloud tool to set project-level conditional bindings.
To set conditional bindings, edit your project's policy.yaml
file by following the process below:
Open the IAM policy for the app using the following gcloud command:
gcloud iap web get-iam-policy --project=PROJECT_ID > policy.yaml
Edit the policy.yaml
file to specify the following:
iap.httpsResourceAccessor
role to grant them access to the resources.The IAM condition.
The following snippet shows an IAM condition with only one attribute specified. This condition grants access to the user and group if the ACCESS_LEVEL_NAME access level requirements are met and the resource URL path starts with /
.
bindings: ... - members: - group:EXAMPLE_GROUP@GOOGLE.COM - user:EXAMPLE_USER@GOOGLE.COM role: roles/iap.httpsResourceAccessor condition: expression: "accessPolicies/ORGANIZATION_NUMBER/accessLevels/ACCESS_LEVEL_NAME" in request.auth.access_levels && request.path.startsWith("/") title: CONDITION_TITLE ...
Bind the policy to the application using the set-iam-policy
command.
gcloud iap web set-iam-policy --project=PROJECT_ID policy.yaml
Your IAM policy now includes a conditional binding.
APITo edit your app's policy.json
file, follow the process below for your app type. See Managing access to IAP-secured resources for more information about using the IAM API to manage access policies.
Before doing the application-specific API steps below, export the following variables:
export PROJECT_NUM=PROJECT_NUMBER export IAP_BASE_URL=https://iap.googleapis.com/v1/projects/${PROJECT_NUM}/iap_web # Replace POLICY_FILE.JSON with the name of JSON file to use for setIamPolicy export JSON_NEW_POLICY=POLICY_FILE.JSONApp Engine
Export the following App Engine variables:
# The APP_ID is usually the project ID export GAE_APP_ID=APP_ID export GAE_BASE_URL=${IAP_BASE_URL}/appengine-${GAE_APP_ID}
Get the IAM policy for the App Engine app using the getIamPolicy
method. The empty data bit at the end turns the curl
request into POST instead of GET.
curl -i -H "Authentication: Bearer $(gcloud auth print-access-token)" \ ${GAE_BASE_URL}/:getIamPolicy -d ''
Add your IAM conditional binding to the IAM policy JSON file. The following is an example of an edited policy.json
file that binds the iap.httpsResourceAccessor
role to two users, granting them access to the IAP-secured resources. An IAM condition has been added to grant them access to the resources only if the ACCESS_LEVEL_NAME access level requirement is met and the resource URL path starts with /
. There can be only one condition per binding.
Example policy.json file
{ "policy": { "bindings": [ { "role": "roles/iap.httpsResourceAccessor", "members": [ "group:EXAMPLE_GROUP@GOOGLE.COM", "user:EXAMPLE_USER@GOOGLE.COM" ], "condition": { "expression": ""accessPolicies/ORGANIZATION_NUMBER/accessLevels/ACCESS_LEVEL_NAME" in request.auth.access_levels && request.path.startsWith("/")", "title": "CONDITION_NAME" } } ] } }
Set your new policy.json
file using the setIamPolicy
method.
curl -i -H "Authentication: Bearer $(gcloud auth print-access-token)" \ ${GAE_BASE_URL}:setIamPolicy -d @${JSON_NEW_POLICY}
You can also update the IAM policy of a App Engine service, all versions, or a specific version of a service. To do this for specific version of a service:
export GAE_SERVICE=SERVICE_NAME export GAE_VERSION=VERSION_NAME
export GAE_BASE_URL=${IAP_BASE_URL}/appengine-${GAE_APP_ID}/services/${GAE_SERVICE}/versions/${GAE_VERSION}
getIamPolicy
and setIamPolicy
commands shown above.Export the project ID of your backend service.
export BACKEND_SERVICE_NAME=BACKEND_SERVICE_NAME
Get the IAM policy for the Compute Engine app using the getIamPolicy
method. The empty data bit at the end turns the curl
request into POST instead of GET.
curl -i -H "Authentication: Bearer $(gcloud auth print-access-token)" \ ${IAP_BASE_URL}/compute/services/${BACKEND_SERVICE_NAME}:getIamPolicy \ -d ''
Add your IAM conditional binding to the IAM policy JSON file. The following is an example of an edited policy.json
file that binds the iap.httpsResourceAccessor
role to two users, granting them access to the IAP-secured resources. An IAM condition has been added to grant them access to the resources only if the ACCESS_LEVEL_NAME access level requirement is met and the resource URL path starts with /
. There can be only one condition per binding.
Example policy.json file
{ "policy": { "bindings": [ { "role": "roles/iap.httpsResourceAccessor", "members": [ "group":EXAMPLE_GROUP@GOOGLE.COM, "user:EXAMPLE_USER@GOOGLE.COM" ], "condition": { "expression": ""accessPolicies/ORGANIZATION_NUMBER/accessLevels/ACCESS_LEVEL_NAME" in request.auth.access_levels && request.path.startsWith("/")", "title": "CONDITION_NAME" } } ] } }
Set your new policy.json
file using the setIamPolicy
method.
curl -i -H "Content-Type:application/json" \ -H "Authentication: Bearer $(gcloud auth print-access-token)" \ ${IAP_BASE_URL}/compute/services/${BACKEND_SERVICE_NAME}:setIamPolicy \ -d @${JSON_NEW_POLICY}
Access to your app can be secured using the hostname and path of a request URL. For example, the request.path.startsWith
IAM condition can be used to only grant access to employees in the Privileged Access group if the URL path starts with /admin
.
For more information about using hostname and path conditions, see request attributes.
String normalizationA URL has a hostname and path. For example, the URL https://sheets.google.com/create?query=param
has a hostname of sheets.google.com
and a path of /create
.
Backends can interpret hostnames and paths in different ways. To remove ambiguity, IAP normalizes hostname and path strings when checking policies.
IAP performs two policy checks when a request has a non-normalized path. If the non-normalized path passes the policy check, IAP normalizes the path and a second policy check is performed. Access is granted if both the non-normalized and normalized paths pass the policy check.
For example, if a request has the path /internal;some_param/admin
, IAP first performs a policy check on the non-normalized path (/internal
). If that passes, IAP performs a second policy check on the normalized path (/internal/admin
).
Hostnames are normalized by:
Hostnames that include non-ASCII characters are further normalized with punycoding. You need to punycode your hostname string for a match to be made.
To punycode your hostname string, use a converter like Punycoder.
The following are examples of normalized hostnames:
FOO.com
is normalized to foo.com
café.fr
is normalized to xn--caf-dma.fr
Paths are normalized by:
A path param includes all characters from a ;
to either the next /
or the end of the path.
Requests that contain ..;
at the beginning of a path section are considered invalid. For example, /..;bar/
and /bar/..;/
return the HTTP 400: Bad Request
error.
The following are examples of normalized paths:
/internal;some_param/admin
is normalized to /internal/admin
/a/../b
is normalized to /b
/bar;param1/baz;baz;param2
is normalized to /bar/baz
A policy set with request.host.endsWith("google.com")
will match to both sub_domain.google.com
and testgoogle.com
. If your goal is to limit your policy to all subdomains the end with google.com
, set your policy to request.host.endsWith(".google.com")
.
Note that setting your policy to request.host.endsWith(".google.com")
will match with sub_domain.google.com
but won't match with google.com
due to the additional .
.
Enabling Cloud Audit Logs for your IAP-secured project allows you to see authorized and unauthorized access requests. View requests and all the access levels a requestor has met by following the process below:
i
icon.!!
icon.protoPayload
> requestMetadata
> requestAttributes
> auth
> accessLevels
.Note that all access levels that a user has met are visible when viewing a request, including access levels that weren't required to access it. Viewing an unauthorized request doesn't indicate what access levels weren't met. This is determined by comparing the conditions on the resource to the access levels visible on the request.
See the Cloud Audit Logs guide for more information about logs.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This guide outlines how to enhance Identity-Aware Proxy (IAP) access policies by integrating access levels and the Identity and Access Management (IAM) Conditions Framework, allowing for refined control over resource access."],["Access levels can restrict access based on IP addresses and end-user device attributes, while IAM conditions enable restrictions based on URL hosts, paths, and date/time."],["Implementing these policies can allow granting access to employees based on whether they are using trusted devices on the corporate network, or only allowing those in the Privileged Access group if they request URLs that start with /admin."],["Setting up access levels involves defining restrictions based on IP addresses or device attributes, with the access level name used to link the level to a specific IAP-secured app."],["Adding conditional bindings to an app's IAM policy further restricts access based on attributes like access levels, URL hosts/paths, and date/time, which can be configured through the Google Cloud console, `gcloud` tool, or API."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4