Skip to content

[googleapis_auth] Support external_account credentials for Workload Identity Federation#728

Merged
kevmoo merged 6 commits intomasterfrom
wif
Mar 3, 2026
Merged

[googleapis_auth] Support external_account credentials for Workload Identity Federation#728
kevmoo merged 6 commits intomasterfrom
wif

Conversation

@kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Feb 28, 2026

Features:

  • Add support for external_account type in Application Default Credentials (ADC).
  • Add StsAuthClient and clientViaStsTokenExchange to handle token exchange with Google SecurityToken Service.
  • Implement file-sourced and url-sourced credentials for STS exchange.

Tests:

  • Add sts_auth_client_test.dart to verify token exchange functionality.
  • Update adc_test.dart to verify external_account flow.

…actor _FlowClient

Features:
- Add support for `impersonated_service_account` type in Application Default Credentials (ADC).
- Propagate `quota_project_id` for Service Account credentials in ADC.
- Add `ImpersonatedAuthClient` and `clientViaServiceAccountImpersonation` which accept an optional baseClient.

Tests:
- Add `adc_impersonation_test.dart` to verify full impersonation flow.
…dentity Federation

Features:
- Add support for `external_account` type in Application Default Credentials (ADC).
- Add `StsAuthClient` and `clientViaStsTokenExchange` to handle token exchange with Google SecurityToken Service.
- Implement file-sourced and url-sourced credentials for STS exchange.

Tests:
- Add `sts_auth_client_test.dart` to verify token exchange functionality.
- Update `adc_test.dart` to verify `external_account` flow.
@kevmoo kevmoo changed the base branch from master to feature_ADC February 28, 2026 18:45
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly extends the 'googleapis_auth' library's Application Default Credentials (ADC) functionality. It introduces robust support for 'impersonated_service_account' credentials and 'external_account' credentials, which are crucial for Workload Identity Federation (WIF). These additions enable more flexible and secure authentication patterns, particularly for environments where external identities need to access Google Cloud resources or where one service account needs to act as another. The changes also ensure proper propagation of 'quota_project_id' for service account-based authentication.

Highlights

  • Enhanced Application Default Credentials (ADC) Support: ADC now recognizes and processes 'impersonated_service_account' and 'external_account' credential types, expanding its authentication capabilities.
  • Workload Identity Federation (WIF) Integration: Introduced 'StsAuthClient' to facilitate token exchange with the Google Security Token Service (STS), enabling external workloads to authenticate with Google Cloud.
  • Service Account Impersonation: Implemented logic within ADC to handle service account impersonation, allowing credentials to act on behalf of another service account.
  • Quota Project Propagation: Ensured that 'quota_project_id' specified in ADC files is correctly propagated for Service Account credentials.
  • New Test Coverage: Added comprehensive tests for the new 'impersonated_service_account' and 'external_account' credential flows, as well as for the 'StsAuthClient'.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • googleapis_auth/CHANGELOG.md
    • Added support for 'impersonated_service_account' source files in Application Default Credentials (ADC).
    • Added support for 'external_account' source files for Workload Identity Federation using 'Google Security Token Service' in Application Default Credentials (ADC).
    • Implemented propagation of 'quota_project_id' for Service Account credentials in Application Default Credentials (ADC).
Activity
  • The pull request incorporated feedback, specifically addressing the use of pattern matching in the newly introduced 'StsAuthClient' as noted in the description.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
googleapis_auth Non-Breaking 2.1.0 2.2.0-wip 2.2.0-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

Unused Dependencies ✔️
Package Status
googleapis_auth ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

License Headers ✔️
//
Files
no missing headers

All source files should start with a license header.

This check can be disabled by tagging the PR with skip-license-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Copy link

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

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 adds support for external_account credentials to enable Workload Identity Federation. This is a significant feature addition, including a new StsAuthClient for handling Security Token Service exchanges, and updates to Application Default Credentials logic to use it. The changes are well-structured and include corresponding tests. I've found a potential issue with error handling and a small opportunity for code simplification in the new StsAuthClient.

@kevmoo kevmoo changed the title wif [googleapis_auth] Support external_account credentials for Workload Identity Federation Feb 28, 2026
@kevmoo
Copy link
Collaborator Author

kevmoo commented Feb 28, 2026

take a look @demolaf

@kevmoo
Copy link
Collaborator Author

kevmoo commented Feb 28, 2026

/gemini review

Copy link

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

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 external_account credentials, enabling Workload Identity Federation. The implementation includes a new StsAuthClient for handling token exchange with the Security Token Service, and updates to Application Default Credentials logic to integrate this new flow. The changes are well-structured, leverage modern Dart features for clarity, and are accompanied by thorough tests. I have one suggestion to improve error handling consistency in the new StsAuthClient.

@kevmoo
Copy link
Collaborator Author

kevmoo commented Feb 28, 2026

/gemini review

Copy link

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

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 adds support for external_account credentials, enabling Workload Identity Federation. The changes include a new StsAuthClient for handling token exchange with the Google Security Token Service, and updates to Application Default Credentials (ADC) logic to use this new client. The implementation correctly handles both file-sourced and URL-sourced subject tokens, as well as optional service account impersonation. The code is well-structured and includes comprehensive tests for the new functionality. My feedback includes a minor suggestion to improve an error message for better clarity.

Base automatically changed from feature_ADC to master March 2, 2026 20:20
@kevmoo kevmoo merged commit ddc2748 into master Mar 3, 2026
34 checks passed
@kevmoo kevmoo deleted the wif branch March 3, 2026 02:43
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.

1 participant