feat: Enable mTLS if GOOGLE_API_USE_CLIENT_CERTIFICATE is not set, if the MWID/X.509 cert sources detected#1848
Merged
nbayati merged 12 commits intogoogleapis:mainfrom Nov 4, 2025
Conversation
84bf5ac to
b13eb7a
Compare
sai-sunder-s
previously approved these changes
Oct 28, 2025
daniel-sanche
requested changes
Oct 29, 2025
sai-sunder-s
previously approved these changes
Oct 31, 2025
nbayati
requested changes
Oct 31, 2025
…f not set, if the MWID/X.509 cert sources detected Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
…or updates to docsting and indentation Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
…he json and return the exact value set by user, and not handling the case when user is setting value to an unsupported value Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
…thod to catch exceptions and update docstring Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
902d039 to
09b6a1e
Compare
andyrzhao
previously approved these changes
Nov 3, 2025
Contributor
andyrzhao
left a comment
There was a problem hiding this comment.
LGTM overall. Please address other reviewer's comments. Thanks!
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
daniel-sanche
previously approved these changes
Nov 3, 2025
Collaborator
daniel-sanche
left a comment
There was a problem hiding this comment.
Left a couple suggestions to consider, but LGTM
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
63e678f
| return crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey) | ||
|
|
||
|
|
||
| def check_use_client_cert(): |
Contributor
Author
There was a problem hiding this comment.
Please note: That here the function is emitting str instead of boolean because we want to also consider the value set by user for GOOGLE_API_USE_CLIENT_CERTIFICATE
nbayati
approved these changes
Nov 3, 2025
daniel-sanche
approved these changes
Nov 3, 2025
sai-sunder-s
approved these changes
Nov 3, 2025
agrawalradhika-cell
added a commit
that referenced
this pull request
Nov 5, 2025
… enables mTLS if GOOGLE_API_USE_CLIENT_CERTIFICATE is not set, when the MWID/X.509 cert sources detected (#1859) Add public wrapper for check_use_client_cert which enables mTLS if GOOGLE_API_USE_CLIENT_CERTIFICATE is not set, when the MWID/X.509 cert sources detected. Also, fix check_use_client_cert to return boolean value. Change #1848 added the check_use_client_cert method that helps know if client cert should be used for mTLS connection. However, that was in a private class, thus, created a public wrapper of the same function so that it can be used by python Client Libraries. Also, updated check_use_client_cert to return a boolean value instead of existing string value for better readability and future scope. --------- Signed-off-by: Radhika Agrawal <agrawalradhika@google.com> Co-authored-by: Daniel Sanche <d.sanche14@gmail.com>
This was referenced Nov 5, 2025
Linchin
added a commit
that referenced
this pull request
Nov 5, 2025
Librarian Version: v0.5.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator:latest <details><summary>google-auth: 2.43.0</summary> ## [2.43.0](v2.42.1...v2.43.0) (2025-11-05) ### Features * Add public wrapper for _mtls_helper.check_use_client_cert which enables mTLS if GOOGLE_API_USE_CLIENT_CERTIFICATE is not set, when the MWID/X.509 cert sources detected (#1859) ([1535ecc](1535eccb)) * Enable mTLS if GOOGLE_API_USE_CLIENT_CERTIFICATE is not set, if the MWID/X.509 cert sources detected (#1848) ([395e405](395e405b)) * onboard `google-auth` to librarian (#1838) ([c503eaa](c503eaa5)) </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Python SDK will use a hybrid approach for mTLS enablement:
** This change also adds the helper method
check_use_client_certand it's unit test, which will be used for checking the criteria for setting the mTLS to true** This change is only for Auth-Library, other changes will be created for Client-Library use-cases.