Skip to content

feat(auth): support external_account_authorized_user credentials - #7225

Open
SamuelXing wants to merge 2 commits into
googleapis:mainfrom
SamuelXing:feat/external-account-authorized-user
Open

SamuelXing wants to merge 2 commits into
googleapis:mainfrom
SamuelXing:feat/external-account-authorized-user

Conversation

@SamuelXing

Copy link
Copy Markdown

Fixes #7224

Workforce Identity Federation users who sign in with gcloud auth application-default login --login-config=... get an ADC file of type external_account_authorized_user. ADC currently rejects that file because it doesn't know the type. This PR adds a credentials::external_account_authorized_user module, modeled on user_account, and wires it into ADC.

Behavior, matching the Node.js ExternalAccountAuthorizedUserClient:

  • Access tokens are refreshed by POSTing grant_type=refresh_token&refresh_token=... (form-encoded) to token_url, with HTTP Basic client authentication (client_id:client_secret).
  • If STS returns a rotated refresh_token, it is used for subsequent refreshes.
  • If token_url is not set, it defaults to https://sts.{universe_domain}/v1/oauthtoken.
  • token_type defaults to Bearer when STS omits it.
  • audience, token_info_url and revoke_url are accepted but not needed to refresh tokens.
  • Building a signer from this type returns not_supported, the same as authorized_user.

Builder API: with_token_url, with_quota_project_id, with_universe_domain, retry/backoff/throttler, build() and build_access_token_credentials(). Scopes from the ADC builder are ignored, because the refresh grant doesn't take scopes. user_account handles universe domain the same way.

Tests: unit tests cover parsing, the request shape (Basic auth and form body), refresh-token rotation, caching, quota project, universe domain and default token URL, and retry vs. non-retry errors. There is also an ADC-level test that loads the file through GOOGLE_APPLICATION_CREDENTIALS. cargo test -p google-cloud-auth, cargo clippy --all-targets --all-features -D warnings and cargo fmt all pass locally.

🤖 Generated with Claude Code

@SamuelXing
SamuelXing requested review from a team as code owners October 16, 2026 21:27
@google-cla

google-cla Bot commented Oct 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Workforce Identity Federation user credentials (external_account_authorized_user) in the google-cloud-auth crate, including a new credentials module, builder, token provider, and unit tests. The feedback recommends optimizing the token provider by instantiating and reusing a single reqwest::Client instead of recreating it on every token refresh request, which prevents connection pooling and can lead to socket exhaustion under load.

Comment thread src/auth/src/credentials/external_account_authorized_user.rs
Comment thread src/auth/src/credentials/external_account_authorized_user.rs
Comment thread src/auth/src/credentials/external_account_authorized_user.rs Outdated
Comment thread src/auth/src/credentials/external_account_authorized_user.rs
Comment thread src/auth/src/credentials/external_account_authorized_user.rs
Comment thread src/auth/src/credentials/external_account_authorized_user.rs
@SamuelXing
SamuelXing force-pushed the feat/external-account-authorized-user branch from 3cc170e to 8efb017 Compare October 16, 2026 23:56
Workforce Identity Federation users who sign in with
`gcloud auth application-default login --login-config=...` get an ADC
file of type `external_account_authorized_user`. Add a credentials
module for this type and wire it into ADC.

Access tokens are refreshed via the STS refresh token grant, using
HTTP Basic client authentication, matching the Node.js implementation.
Rotated refresh tokens are used for subsequent refreshes, and the token
URL defaults to `https://sts.{universe_domain}/v1/oauthtoken`.
@SamuelXing
SamuelXing force-pushed the feat/external-account-authorized-user branch from 8efb017 to a50b4f6 Compare October 17, 2026 01:10

This branch has not been deployed

No deployments
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.

feat(auth): support external_account_authorized_user credentials

2 participants