Skip to content

feat(auth): deprecate unsafe credentials JSON loading options#13397

Merged
quartzmo merged 5 commits intogoogleapis:mainfrom
quartzmo:windy-eagle-mitigation
Dec 2, 2025
Merged

feat(auth): deprecate unsafe credentials JSON loading options#13397
quartzmo merged 5 commits intogoogleapis:mainfrom
quartzmo:windy-eagle-mitigation

Conversation

@quartzmo
Copy link
Member

  • Add deprecation comments to credentials.DetectOptions.CredentialsFile
    and credentials.DetectOptions.CredentialsJSON.
  • Update documentation to recommend new safe load methods.
  • Add credentials.CredentialsType.
  • Add credentials.NewCredentialsFromJSON and credentials.NewCredentialsFromFile.
  • Add deprecation comments to idtoken.Options.CredentialsFile
    and idtoken.Options.CredentialsJSON.
  • Add idtoken.NewCredentialsFromJSON and idtoken.NewCredentialsFromFile.
  • Replace internal integer-based CredentialsType (iota) with
    public string-based constants for specifying credential file
    types. This change:
    • Eliminates the zero-value problem
    • Improves readability and debugging
    • Ensures consistency with JSON data

* Add deprecation comments to credentials.DetectOptions.CredentialsFile
  and credentials.DetectOptions.CredentialsJSON.
* Update documentation to recommend new safe load methods.
* Add credentials.CredentialsType.
* Add credentials.NewCredentialsFromJSON and credentials.NewCredentialsFromFile.
* Add deprecation comments to idtoken.Options.CredentialsFile
  and idtoken.Options.CredentialsJSON.
* Add idtoken.NewCredentialsFromJSON and idtoken.NewCredentialsFromFile.
  * Replace internal integer-based `CredentialsType` (iota) with
    public string-based constants for specifying credential file
    types. This change:
    * Eliminates the zero-value problem
    * Improves readability and debugging
    * Ensures consistency with JSON data
@quartzmo quartzmo requested a review from a team as a code owner November 21, 2025 19:44
@quartzmo quartzmo requested review from a team and sai-sunder-s November 21, 2025 19:44
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @quartzmo, 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 refactors how credential configurations are handled, primarily focusing on improving security and clarity. It introduces new, type-specific functions for loading credentials from files or JSON, which enforce type validation and provide explicit security warnings for certain credential types. Concurrently, older, less secure methods for loading credentials directly via DetectOptions and idtoken.Options fields have been deprecated, guiding users towards the new, safer alternatives. These changes aim to prevent accidental loading of malicious or unexpected credential types and promote best practices for handling sensitive authentication data.

Highlights

  • Credential Type Standardization: Introduced a new public CredentialsType string enum to replace an internal integer-based CredentialType, improving readability, debugging, and consistency across credential handling.
  • New Credential Loading Functions: Added credentials.NewCredentialsFromJSON and credentials.NewCredentialsFromFile for safer, type-specific loading of credentials, which includes validation against the expected credential type.
  • Deprecation of Direct Credential Fields: Deprecated credentials.DetectOptions.CredentialsFile and CredentialsJSON, as well as idtoken.Options.CredentialsFile and CredentialsJSON, recommending the new type-specific loading functions due to potential security risks with untrusted sources.
  • ID Token Credential Loading: Introduced idtoken.NewCredentialsFromJSON and idtoken.NewCredentialsFromFile to provide type-validated loading for ID token credentials, enhancing security for this specific credential type.
  • Enhanced Security Guidance: Updated documentation and deprecation messages to strongly advise validating credential configurations from external sources to mitigate security risks associated with unvalidated inputs.
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.

@quartzmo quartzmo changed the title Windy eagle mitigation feat(auth): deprecate unsafe credentials JSON loading options Nov 21, 2025
Copy link
Contributor

@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 significant security improvements by deprecating unsafe credential loading methods and adding new, safer alternatives that require explicit credential type specification. The move from integer-based iota to string constants for credential types is a great change for readability and robustness. The new functions are well-documented with clear security warnings, and the deprecation messages for the old fields are very informative. The changes are supported by a good set of new tests. I have identified a couple of important issues regarding context.Context propagation in the new functions that should be addressed before merging.

@quartzmo quartzmo force-pushed the windy-eagle-mitigation branch from 2026c11 to f66176d Compare November 21, 2025 20:03
Copy link
Member

@hongalex hongalex left a comment

Choose a reason for hiding this comment

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

approved with comment nit

@quartzmo quartzmo merged commit 0dd2a3b into googleapis:main Dec 2, 2025
9 checks passed
@quartzmo quartzmo deleted the windy-eagle-mitigation branch December 2, 2025 22:54
krishnamd-jkp pushed a commit to krishnamd-jkp/google-cloud-go that referenced this pull request Dec 8, 2025
…apis#13397)

* Add deprecation comments to credentials.DetectOptions.CredentialsFile
  and credentials.DetectOptions.CredentialsJSON.
* Update documentation to recommend new safe load methods.
* Add credentials.CredentialsType.
* Add credentials.NewCredentialsFromJSON and
credentials.NewCredentialsFromFile.
* Add deprecation comments to idtoken.Options.CredentialsFile
  and idtoken.Options.CredentialsJSON.
* Add idtoken.NewCredentialsFromJSON and idtoken.NewCredentialsFromFile.
* Replace internal integer-based `CredentialsType` (iota) with
  public string-based constants for specifying credential file
  types. This change:
  * Eliminates the zero-value problem
  * Improves readability and debugging
  * Ensures consistency with JSON data
bhshkh added a commit that referenced this pull request Dec 15, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.7.0
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:718167d5c23ed389b41f617b3a00ac839bdd938a6bd2d48ae0c2f1fa51ab1c3d
<details><summary>auth: 0.18.0</summary>

##
[0.18.0](auth/v0.17.0...auth/v0.18.0)
(2025-12-15)

### Features

* deprecate unsafe credentials JSON loading options (#13397)
([0dd2a3b](0dd2a3bd))

* Support scopes field from impersonated credential json (#13308)
([e3f62e1](e3f62e10))

* add support for parsing EC private key (#13317)
([ea6bc62](ea6bc62f))

</details>
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.

3 participants