Google Cloud IAP (Identity-Aware Proxy) controls access to your staging environment by verifying a user’s identity and context before they reach the app—so you can’t bypass it by knowing the URL. You configure IAP on the load balancer or backend service, and it intercepts every request, blocking anyone who isn’t authenticated and authorized. This article explains how IAP works for staging, what bypass checks exist (and why they fail), and how to set it up correctly.
What Is IAP and Why Use It for Staging?
IAP is a Google Cloud service that sits in front of your applications and enforces access policies based on Google identity, not network location. For a staging environment, you typically want only your team to see unfinished features and test data. IAP gives you that without maintaining a VPN or managing firewall rules for each developer’s IP.
Unlike a traditional firewall that trusts anyone inside the network, IAP checks each request’s authentication and authorization. It works with Google accounts (including G Suite or Cloud Identity) and can also check additional context like the user’s IP address, device state, and time of day. That means a stolen URL or a leaked staging link won’t help an outsider—they still need a valid Google account with the right IAM role.
How IAP Works: The Request Flow
When a user hits your staging URL, the request goes to the load balancer, which forwards it to IAP. IAP then does the following:
- Checks if the user has an active Google session (via cookies or OAuth tokens).
- If not authenticated, redirects to the Google sign-in page.
- After sign-in, checks the IAM policy to see if the user has the
roles/iap.httpsResourceAccessorrole on the resource. - Optionally evaluates additional context (IP ranges, device policy, etc.) if you’ve set them.
- If all checks pass, the request is forwarded to your backend; otherwise, a 403 is returned.
This happens for every single request, including static assets and API calls. You don’t need to change your application code—IAP works at the infrastructure layer.
Can You Bypass IAP? Common Misconceptions
People often ask if they can bypass IAP by directly hitting the backend IP, using a different domain, or sending a spoofed header. Let’s address each:
- Direct IP access: If your backend is behind a load balancer and not exposed with a public IP, IAP is the only entry point. If you’ve accidentally given the VM a public IP, IAP won’t protect that path—you must remove it.
- Different domain: IAP is attached to the backend service, not the domain. Any hostname that routes to that backend goes through IAP.
- Spoofing headers: IAP validates the JWT token signed by Google. A fake
x-goog-authenticated-user-emailheader is ignored because the backend checks the token’s signature. - Service account keys: If you have a service account key with the right role, you can get a token and access IAP. That’s not a bypass—it’s a legitimate credential. Protect keys carefully.
The only true bypass is misconfiguration: exposing a backend without IAP, having overly broad IAM roles, or leaving a service account key in a public repo. IAP itself is robust.
Setting Up IAP for Staging: Step-by-Step
Here’s a typical setup for a staging environment behind a load balancer:
- Create a backend service in Cloud Load Balancing and add your instance group (or serverless NEG) as the backend.
- Enable IAP on that backend service: go to Security → Identity-Aware Proxy, select the resource, and turn on IAP.
- Grant access: add your team members as principals and assign the
IAP-secured Web App Userrole. - Configure the OAuth consent screen and create credentials (Web Client ID) if you’re using the default sign-in flow.
- Test with an incognito window and a non-team Google account—you should get a 403.
For serverless (Cloud Run, App Engine), the process is similar but you enable IAP on the serverless service directly. Note that IAP requires a load balancer for Compute Engine VMs; it doesn’t work on a bare VM with a public IP.
IAP vs. VPN or IP Whitelisting
Many staging setups use a VPN or restrict access by IP. IAP offers distinct advantages:
- No network management: No VPN servers, certificates, or client software to maintain.
- Granular user control: Add/remove a developer in seconds via IAM, no need to update firewall rules.
- Context-aware access: You can require that users be on a corporate network or have a company-managed device.
- Audit logging: IAP logs every access attempt, which helps you see who accessed staging and when.
IP whitelisting is simpler but brittle: developers’ IPs change, and anyone on a shared network gets access. VPNs are secure but add overhead. IAP is a middle ground that’s often the right fit for staging.
Common Problems and How to Fix Them
- Users get 403 even after granting access: Check that you assigned the role to the user, not a group that doesn’t exist. Also, wait a few minutes for IAM propagation.
- OAuth consent screen errors: Make sure your app’s domain is verified and the redirect URI matches your load balancer’s domain.
- IAP doesn’t work with Cloud Run: For Cloud Run, you need to enable IAP on the service and also set
ingress: internalso only the load balancer can reach it. - Staging API calls fail because of missing tokens: If your frontend calls the backend, you need to propagate the IAP JWT. Use the
x-goog-iap-jwt-assertionheader and verify it in your backend. - Too many redirects: This often happens when the load balancer isn’t terminating SSL properly. Ensure your HTTPS certificate is valid and the backend protocol is HTTP/HTTPS as expected.
Costs and Alternatives
IAP itself has no additional cost beyond the standard load balancer and network egress charges. You pay for the load balancer, which you’d likely have anyway. If you’re using Cloud Run or App Engine, IAP is free of extra charges.
Alternatives include:
- Firewall rules with source IP ranges: Simple but not user-based.
- Cloud Identity-Aware Proxy vs. BeyondCorp Enterprise: BeyondCorp adds device trust and DLP, but it’s a paid product. For basic staging, IAP is enough.
- Service accounts for programmatic access: If your staging is only accessed by CI/CD, you can use service account tokens instead of user accounts.
Frequently Asked Questions
Can I use IAP for SSH access to staging VMs?
Yes, IAP supports TCP forwarding for SSH and RDP. You can enable IAP on the tunnel and then use gcloud compute ssh with the --tunnel-through-iap flag. This is a secure way to manage staging VMs without opening port 22 to the internet.
Does IAP work with non-Google identity providers (like Okta)?
Yes, you can use an external identity provider by configuring federated identity with Google Cloud. Users sign in via your IdP, and IAP trusts the Google-issued token. This requires setting up a workforce identity federation or using a third-party IdP that supports OIDC.
How do I allow a service account to access staging via IAP?
Grant the service account the roles/iap.httpsResourceAccessor role on the IAP resource. Then, the service account can generate an OAuth token (using its key) and include it in the request’s Authorization header. This is common for CI/CD pipelines that need to run tests against staging.
Can I bypass IAP for health checks?
Yes, you can create a separate backend service for health checks that doesn’t have IAP enabled. But be careful: this exposes the health check path to the internet. A better approach is to use a firewall rule that only allows Google’s health check IP ranges to reach the backend.
What happens if IAP is disabled temporarily?
Disabling IAP on the backend service immediately makes the resource accessible to anyone who can reach the load balancer. If you need to disable it for maintenance, make sure you also restrict access via firewall rules or shut down the backend to avoid exposure.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Infinity Essence in Sailor Piece: Farming and Uses
- Apollo.io Alternatives for Sales Prospecting
- Deploy AI Agents in a Service Desk With Human Oversight
- AIM and Yahoo Profiles: When Did You Last Look?
- Best Smartwatch Under ₹5,000 in India: What to Buy
- Chat History vs Saved Memory in AI Assistants