-
Notifications
You must be signed in to change notification settings - Fork 167
feat: Auto enable mTLS when supported certificates are detected #1637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Auto enable mTLS when supported certificates are detected #1637
Conversation
Summary of ChangesHello @agrawalradhika-cell, 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 enhances the Google Cloud Python SDK's handling of mutual TLS (mTLS) by introducing a more sophisticated and adaptive enablement mechanism. It prioritizes explicit user control through an environment variable while also enabling mTLS automatically in secure environments where specific certificate sources are detected. This change aims to improve security posture by default for supported authentication methods without requiring manual configuration, while maintaining flexibility for users who need precise control. 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.
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 logic to automatically enable mTLS when supported certificates are detected, falling back to environment variables for older google-auth versions. The changes are mostly good refactorings to centralize this logic. However, I found a critical bug in google/cloud/storage/client.py where a module is used without being imported, which will lead to a NameError. I've suggested a fix for the import and also a refactoring to simplify some duplicated code in the same file.
|
kokoro failure should be fixed once this is merged - #1635 |
Signed-off-by: Radhika Agrawal <[email protected]>
…sport.mtls Signed-off-by: Radhika Agrawal <[email protected]>
Signed-off-by: Radhika Agrawal <[email protected]>
Signed-off-by: Radhika Agrawal <[email protected]>
3840afe to
bfa8a2b
Compare
daniel-sanche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can ignore my comments on the auto-generated code, those should have been left in the gapic-generator PR
Hand-wrritten changes LGTM
🤖 I have created a release *beep* *boop* --- ## [3.7.0](v3.6.0...v3.7.0) (2025-12-09) ### Features * Auto enable mTLS when supported certificates are detected ([#1637](#1637)) ([4e91c54](4e91c54)) * Send entire object checksum in the final api call of resumable upload ([#1654](#1654)) ([ddce7e5](ddce7e5)) * Support urllib3 >= 2.6.0 ([#1658](#1658)) ([57405e9](57405e9)) ### Bug Fixes * **bucket:** Move blob fails when the new blob name contains characters that need to be url encoded ([#1605](#1605)) ([ec470a2](ec470a2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Chandra Shekhar Sirimala <[email protected]>
The Python SDK will use a hybrid approach for mTLS enablement:
If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is set (either true or false or any value), the SDK will respect that setting. This is necessary for test scenarios and users who need to explicitly control mTLS behavior.
If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not set, the SDK will automatically enable mTLS only if it detects Managed Workload Identity (MWID) or X.509 Workforce Identity Federation (WIF) certificate sources. In other cases where the variable is not set, mTLS will remain disabled.