feat(auth): deprecate unsafe credentials JSON loading options#13397
feat(auth): deprecate unsafe credentials JSON loading options#13397quartzmo merged 5 commits intogoogleapis:mainfrom
Conversation
* 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
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
2026c11 to
f66176d
Compare
…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
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>
and credentials.DetectOptions.CredentialsJSON.
and idtoken.Options.CredentialsJSON.
CredentialsType(iota) withpublic string-based constants for specifying credential file
types. This change: