Skip to content

Conversation

@djc
Copy link
Owner

@djc djc commented Jun 28, 2023

While we're not sure this is a regression since #67 we've recently been seeing elevated error rates in production for some of our code running gcp_auth in a Docker container that has the gcloud CLI installed. The error looks like this (this is from a gRPC client call):

Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Code that doesn't have gcloud installed in the container seems to be running without errors.

The documentation for the print-access-token command also lists some limitations:

Note that token itself may not be enough to access some services. If you use the token with curl or similar tools, you may see permission errors similar to "API has not been used in project 32555940559 before or it is disabled.". If it happens, you may need to provide a quota project in the "X-Goog-User-Project" header.

The identity that granted the token must have the serviceusage.services.use permission on the provided project.

We also noted that the order of token acquisition methods tried by the gcp_auth::AuthenticationManager doesn't match what official Google SDKs do -- this PR would bring gcp_auth closer in line with official SDKs.

Because this seems like a substantial change to the documented mechanics, I've included a commit that bumps the version number to the next semver-incompatible release (despite there being no actual changes to the public API). When releasing this change we should publish release notes that clearly point out the change.

(I worked with @valkum on this, hope I'm correctly representing his research.)

@djc djc requested a review from hrvolapeter June 28, 2023 15:01
Copy link
Collaborator

@hrvolapeter hrvolapeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'm just thinking since the order is already being changed if it doesn't make sense to bring the ADC as last step to have the same order as other SDKs

@djc djc force-pushed the deprioritize-gcloud branch from 144065c to 8876527 Compare June 30, 2023 10:01
@djc
Copy link
Owner Author

djc commented Jun 30, 2023

Okay, I've aligned the order with the upstream SDKs. Also renamed the ServiceAccount impls a bit to try make the names more descriptive.

Copy link
Contributor

@valkum valkum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Just a single thought. But feel free to merge without following my remarks.

@djc djc force-pushed the deprioritize-gcloud branch from 8876527 to f0f7ef7 Compare June 30, 2023 10:46
@djc
Copy link
Owner Author

djc commented Jun 30, 2023

@hrvolapeter thanks for the feedback, please have a look to see if you agree with the renaming!

Copy link
Collaborator

@hrvolapeter hrvolapeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and thanks for the changes! 👍

@djc djc merged commit 6e6a440 into master Jun 30, 2023
@djc
Copy link
Owner Author

djc commented Jun 30, 2023

Published 0.9.0 on crates.io. I was going to add a GitHub release to write some release notes but I don't think I have permissions to do so.

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

Successfully merging this pull request may close these issues.

4 participants