feat: Auto enable mTLS when supported certificates are detected by agrawalradhika-cell · Pull Request #1637 · googleapis/python-storage · GitHub
Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

feat: Auto enable mTLS when supported certificates are detected#1637

Merged
daniel-sanche merged 5 commits into
googleapis:mainfrom
agrawalradhika-cell:update-mtls
Dec 8, 2025
Merged

feat: Auto enable mTLS when supported certificates are detected#1637
daniel-sanche merged 5 commits into
googleapis:mainfrom
agrawalradhika-cell:update-mtls

Conversation

@agrawalradhika-cell

Copy link
Copy Markdown
Contributor

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.

@agrawalradhika-cell agrawalradhika-cell requested review from a team December 4, 2025 10:27
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. labels Dec 4, 2025
@gemini-code-assist

Copy link
Copy Markdown
Contributor

@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 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.

Comment thread google/cloud/storage/client.py Outdated
Comment thread google/cloud/storage/client.py Outdated
@chandra-siri

Copy link
Copy Markdown
Collaborator

@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Dec 5, 2025
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
…sport.mtls

Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Comment thread tests/unit/gapic/storage_v2/test_storage.py
Comment thread tests/unit/gapic/storage_v2/test_storage.py
Comment thread tests/unit/gapic/storage_v2/test_storage.py

@daniel-sanche daniel-sanche 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.

You can ignore my comments on the auto-generated code, those should have been left in the gapic-generator PR

Hand-wrritten changes LGTM

@Linchin Linchin self-requested a review December 5, 2025 21:15
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 5, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 5, 2025
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 8, 2025
@daniel-sanche daniel-sanche enabled auto-merge (squash) December 8, 2025 18:38
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 8, 2025
@daniel-sanche daniel-sanche merged commit 4e91c54 into googleapis:main Dec 8, 2025
14 checks passed
chandra-siri added a commit that referenced this pull request Dec 9, 2025
🤖 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 &gt;= 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 <chandrasiri@google.com>
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Mar 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[3.7.0](googleapis/python-storage@v3.6.0...v3.7.0)
(2025-12-09)


### Features

* Auto enable mTLS when supported certificates are detected
([#1637](googleapis/python-storage#1637))
([4e91c54](googleapis/python-storage@4e91c54))
* Send entire object checksum in the final api call of resumable upload
([#1654](googleapis/python-storage#1654))
([ddce7e5](googleapis/python-storage@ddce7e5))
* Support urllib3 &gt;= 2.6.0
([#1658](googleapis/python-storage#1658))
([57405e9](googleapis/python-storage@57405e9))


### Bug Fixes

* **bucket:** Move blob fails when the new blob name contains characters
that need to be url encoded
([#1605](googleapis/python-storage#1605))
([ec470a2](googleapis/python-storage@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 <chandrasiri@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: storage Issues related to the googleapis/python-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants