Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use in conjunction with IAP in GAE Flex #762

Open
maroux opened this issue Feb 13, 2020 · 13 comments
Open

Unable to use in conjunction with IAP in GAE Flex #762

maroux opened this issue Feb 13, 2020 · 13 comments

Comments

@maroux
Copy link
Contributor

maroux commented Feb 13, 2020

We have a few app engine services which are fronted by IAP (works with Google user auth etc). We also want to deploy a few services which are fronted by ESP (works with Auth0). Because IAP needs to be enabled for the "App Engine app" and can't be selectively enabled for App Engine services, we have to enable IAP for services which are fronted by ESP and add allUsers permission in IAP for those services. Now - the problem is that ESP honors IAP header over Authorization header, and since IAP sets it's header regardless if you use allUsers permissions or not - this leads to ESP services not working even with correct Authorization header.

Note we're using app.yaml ESP configuration method, instead of Cloud Run.

Is there any solution for this situation? Please advise.

@qiwzhang
Copy link
Contributor

qiwzhang commented Feb 13, 2020

Do you need to use ESP for JWT authentication? If not, you can specify Endpoint config that JWT auth is not required, ESP will not check JWT token.

If you need to use JWT authentication feature and IAP, yes, we have a problem, they don't work together. ESP auth always checks IAP header first, if there is a JWT token, just use it. That could be the wrong JWT to check.

One solution is to change ESP not to check IAP header for auth. But we are not sure if such change is safe for all users. Some users maybe using ESP to verify IAP token, such change will break them.

We could add a esp start_up flag to enable such change, but it is not easy for FLEX users to set ESP start_up flags.

Another solution is to enhance Endpoint service config to allow users to specify the locations to extract JWT token.

@maroux
Copy link
Contributor Author

maroux commented Feb 13, 2020

Hm - yes I was hoping to use ESP for JWT authentication and avoid IAP messing it up since I don't have an option to disable IAP selectively. What's the use case for ESP respecting IAP headers?

@qiwzhang
Copy link
Contributor

Some users use ESP to verify IAP signed header, so their backend don't need to verify it.

@qiwzhang
Copy link
Contributor

We are working on an approach to allow users to specify the JWT extracting location in OpenAPI spec.
With this, you can specify where to extract it, you can exclude IAP signed header in your service config.

@maroux
Copy link
Contributor Author

maroux commented Feb 13, 2020

Okay that makes sense. Is there a timeline for when open api spec would support this?

@qiwzhang
Copy link
Contributor

@maroux I am not familiar with how IAP works in GAE. I have a question, if you have IAP enabled for a GAE service, how do you pass auth0 JWT header to it (or its ESP)? JWT token passed by Authorization header will be consumed by IAP in GFE. It will reject the request if it is not intended for IAP. The auth0 JWT will never reach GAE. am I correct?

@maroux
Copy link
Contributor Author

maroux commented Feb 14, 2020

That was my concern as well. But as it turns out, IAP passes through the Authorization header if you don't use it for authentication (i.e. allow all users). Odd that it still tacks on IAP header though.

@maroux
Copy link
Contributor Author

maroux commented May 27, 2020

Hi @qiwzhang is there an update on this? Can we specify JWT extracting location in OpenAPI spec now?

@qiwzhang
Copy link
Contributor

Yes, you can specify x-google-jwt-locations

But it is not implemented in ESPv1, only implemented in ESPv2.
For supporting services deploying in serverless platforms, such as Cloud Run, Cloud Function, and AppEngine standard, we recommend deploying ESPv2 in Cloud Run.

@qiwzhang
Copy link
Contributor

BTW, this doc is still using ESPv1, we will update it to use ESPv2, the instruction should be similar to the one for Cloud Run.

@maroux
Copy link
Contributor Author

maroux commented May 27, 2020

nice!

Follow-up: So to deploy ESP v2 in app engine flex - we'd have to deploy one service for ESP and one for the actual API, correct? Does ESPv2 not support managed config rollout?

(trying to avoid Cloud Run) Does this picture look correct?

(internet) ->
IAP fronting ESP -> allows all users ->
ESP in App Engine Flex -> validates Authorization header instead of IAP header ->
IAP fronting API service -> validates ESP SA
API service in App Engine Flex -> looks at X-Endpoint-API-UserInfo header to get end user info

@maroux
Copy link
Contributor Author

maroux commented May 27, 2020

There's no way to specify ESPv2 here correct?

@qiwzhang
Copy link
Contributor

AppEngine flex has a build-in ESPv1 which is configured the app.yaml, in its endpoints_api_service section (as described here. Sorry, it doesn't support ESPv2.

My suggestion is to deploy ESPv2 on Cloud Run and use x-google-backend to point to your AppEngine service. It could be either AppEngine standard and flex. For Flex, you just don't specify endpoints_api_service to disable ESPv1.

But if you insists on using Flex endpoints_api_service feature, it is ESPv1. You depends on ESPv1 implementation of this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants