Skip to content

Conversation

@google-labs-jules
Copy link

This PR adds support for mTLS endpoints in impersonated credentials.
It updates _mtls_helper.check_use_client_cert to respect CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE.
It also conditionally switches the IAM endpoints in impersonated_credentials.py based on this check.
Tests were updated to verify the new behavior of check_use_client_cert.
Note: Existing test TestDecryptPrivateKey.test_success in tests/transport/test__mtls_helper.py is failing due to OpenSSL.crypto.sign being removed in recent versions of dependencies, which is unrelated to these changes.


PR created automatically by Jules for task 8690199261277670952 started by @amtk3

Conditionally use mTLS endpoints in impersonated credentials if CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE or GOOGLE_API_USE_CLIENT_CERTIFICATE is true.
Updated `_mtls_helper.check_use_client_cert` to check for `CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE`.
Added mTLS endpoints to `google/auth/iam.py`.
Modified `google/auth/impersonated_credentials.py` to use mTLS endpoints when appropriate.
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Conditionally use mTLS endpoints in impersonated credentials if CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE is true or google.auth.transport._mtls_helper.check_use_client_cert() is true.
Added mTLS endpoints to `google/auth/iam.py`.
Modified `google/auth/impersonated_credentials.py` to use mTLS endpoints when appropriate.
Conditionally use mTLS endpoints in impersonated credentials if google.auth.transport._mtls_helper.check_use_client_cert() is true.
Added mTLS endpoints to `google/auth/iam.py`.
Modified `google/auth/impersonated_credentials.py` to use mTLS endpoints when appropriate.
Conditionally use mTLS endpoints in impersonated credentials if google.auth.transport._mtls_helper.check_use_client_cert() is true.
Added mTLS endpoints to `google/auth/iam.py`.
Modified `google/auth/impersonated_credentials.py` to use mTLS endpoints when appropriate.
Removed logic checking for `CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE` environment variable as requested, relying solely on `check_use_client_cert()`.
Conditionally define IAM endpoints in `google/auth/iam.py` based on `google.auth.transport._mtls_helper.check_use_client_cert()`.
If mTLS is enabled, the endpoints will point to `iamcredentials.mtls.googleapis.com`.
This ensures impersonated credentials (and other users of `google.auth.iam`) use mTLS endpoints when appropriate.
Reverted changes to `google/auth/impersonated_credentials.py` as they are now handled by `google/auth/iam.py`.
Conditionally define IAM endpoints in `google/auth/iam.py` based on `google.auth.transport._mtls_helper.check_use_client_cert()`.
If mTLS is enabled, the endpoints will point to `iamcredentials.mtls.googleapis.com`.
Added a safety check using `hasattr` to avoid `AttributeError` if `_mtls_helper` does not have `check_use_client_cert` (e.g. in some bundled environments).
This ensures impersonated credentials (and other users of `google.auth.iam`) use mTLS endpoints when appropriate.
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.

1 participant