cookiesgoogle-kubernetes-enginegoogle-cloud-platformgoogle-iap

Cookie or header to send own API to prevent Google Cloud Identity Aware Proxy (IAP) 302?


I have setup Cloud IAP on a development environment (spun up with Kubernetes and using Let's Encrypt) and everything is working fine.

The setup is pretty basic for this app:

1) An API that has a number of REST endpoints and a persistent data store, in project A

2) A SPA front end app that utilizes said API, in a different project B

In my browser (tried Chrome and Firefox), I can authenticate my Google user in both apps via the IAP screen (by going to each domain in a browser tab), but once I try to use the SPA and it attempts requests to the API, I see the network requests 302 redirect to the Google IAP sign-in page.

Question: Is there a header or cookie that needs to be sent over via the API requests on behalf of the user so that IAP allows pass-thru?

Note I see these two cookies btw GCP_IAAP_AUTH_TOKEN and GCP_IAAP_XSRF_NONCE.


Solution

  • What's protected with IAP, "API" or "SPA"? If it's SPA, IAP should work as normal. If it's API, your best option today is to use https://cloud.google.com/iap/docs/authentication-howto to have SPA authenticate to API, and maybe also have it pass down https://cloud.google.com/iap/docs/signed-headers-howto so that API can separately verify the end-user's credentials.

    Passing down GCP_IAAP_AUTH_TOKEN from SPA to API won't work, we strip that before passing the request to the end-user application for security reasons (in case the transport between the load balancer and the application is HTTP, just to make life a little harder for an attacker.)