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

Invalid IAP credentials: Unable to parse JWT from readme curl cmds #92

Open
ravwojdyla opened this issue Jan 26, 2022 · 3 comments
Open

Comments

@ravwojdyla
Copy link
Contributor

Running readme curl (e.g. list backends) commands returns:

Invalid IAP credentials: Unable to parse JWT

The issue seems to be the token returned by gcloud auth print-access-token, when I retrieve a token using instructions from https://cloud.google.com/iap/docs/authentication-howto it works fine. Am I doing sth wrong or is the readme outdated?

@ojarjur
Copy link
Collaborator

ojarjur commented Jan 27, 2022

@ravwojdyla thanks for reaching out.

I don't think the App Engine app works if you have IAP enabled.

You might be able to get your client-side requests through IAP, but the proxy agent has never been updated to support using OIDC tokens to authenticate instead of OAuth access tokens.

That means that your requests won't make it all the way through to your backend server.

I've sent out #94 to add a note about this to the README

There isn't any sort of fundamental reason that we can't support IAP, but it hasn't been a priority because no one is using it with IAP. That's a bit of a circular argument (no one uses this with IAP because we don't support it, and we don't support IAP because no one uses it with IAP...), but it does mean that this isn't a priority for anyone currently working on the inverting proxy.

That being said, a pull request to add support for OIDC tokens to the proxy agent would be welcome, as long as it's flag controlled (so that existing users can continue to rely on OAuth tokens).

@ravwojdyla
Copy link
Contributor Author

ravwojdyla commented Jan 27, 2022

@ojarjur that explains it, thank you!

You might be able to get your client-side requests through IAP, but the proxy agent has never been updated to support using OIDC tokens to authenticate instead of OAuth access tokens.
..
That being said, a pull request to add support for OIDC tokens to the proxy agent would be welcome, as long as it's flag controlled (so that existing users can continue to rely on OAuth tokens).

Do you foresee it would be something more than adding idtoken.NewClient(ctx, audience) to

func getGoogleClient(ctx context.Context) (*http.Client, error) {

+ flags for using IAP and audience oauth client ID?


Edit: that was definitely, not enough, agent GAE app fails with:

Failed to validate backend ID: "Failed to read the OAuth authorization header: "API error 3 (user: OAUTH_INVALID_TOKEN)""

from pendingHandler in

oauthUser, err := user.CurrentOAuth(ctx, "https://www.googleapis.com/auth/cloud-platform")

@ojarjur
Copy link
Collaborator

ojarjur commented Feb 15, 2022

@ravwojdyla Yeah, it looks like the OIDC token auth and the OAuth user auth are incompatible because they both want to use the same "Authorization" header with different values.

We'd need to change checkBackendID to support OIDC tokens as an alternative to OAuth.

I have no idea how much work that would be as I've never done anything with OIDC

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