Skip to content

fix(auth): configure mTLS for impersonated credentials#17404

Merged
daniel-sanche merged 6 commits into
googleapis:mainfrom
amtk3:main
Jun 11, 2026
Merged

fix(auth): configure mTLS for impersonated credentials#17404
daniel-sanche merged 6 commits into
googleapis:mainfrom
amtk3:main

Conversation

@amtk3

@amtk3 amtk3 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR configures AuthorizedSession to support mutual TLS (mTLS) when refreshing impersonated ID tokens or signing bytes.

Context

When using impersonated credentials (e.g., via gcloud auth print-identity-token --impersonate-service-account=...) in environments where mTLS is enforced by Context Aware Access (CAA) policies, the requests fail with 401 UNAUTHENTICATED (specifically ACCESS_TOKEN_TYPE_UNSUPPORTED).

Although the endpoint correctly resolves to the mTLS domain (iamcredentials.mtls.googleapis.com), the underlying AuthorizedSession created in impersonated_credentials.py is never configured with the client certificate, causing the TLS handshake to lack the required client cert.

Changes

  • google/auth/impersonated_credentials.py:
    • Added authed_session.configure_mtls_channel() in Credentials.sign_bytes right after the session is created.
    • Added authed_session.configure_mtls_channel() in IDTokenCredentials.refresh right after the session is created.
  • tests/test_impersonated_credentials.py:
    • Added test_sign_bytes_configures_mtls and test_id_token_refresh_configures_mtls unit tests to verify configure_mtls_channel is invoked.

google-labs-jules Bot and others added 3 commits June 9, 2026 02:06
…resh

Adds mTLS configuration to AuthorizedSession instances used in
impersonated_credentials.py for `Credentials.sign_bytes` and
`IDTokenCredentials.refresh`. This ensures that when impersonating
credentials in environments enforcing mTLS, the client certificate
is presented during the TLS handshake.

Corresponding tests are added to verify this behavior.

Co-authored-by: amtk3 <254821816+amtk3@users.noreply.github.com>
Adds mTLS configuration to AuthorizedSession instances used in
impersonated_credentials.py for `Credentials.sign_bytes` and
`IDTokenCredentials.refresh`. This ensures that when impersonating
credentials in environments enforcing mTLS, the client certificate
is presented during the TLS handshake.

Corresponding tests are added to verify this behavior.

Co-authored-by: amtk3 <254821816+amtk3@users.noreply.github.com>
…4737746463131592670

fix(auth): enable mTLS on AuthorizedSession in impersonated credentials
@amtk3 amtk3 requested review from a team as code owners June 9, 2026 03:31

@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 configures mTLS channels on the authorized sessions used during byte signing and ID token refresh operations in impersonated_credentials.py. It also adds corresponding unit tests to verify that configure_mtls_channel is called. No review comments were provided, so there is no feedback to address.

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

LGTM

google-labs-jules Bot and others added 3 commits June 10, 2026 02:30
Reformatted packages/google-auth/tests/test_impersonated_credentials.py
with `black` to adhere to the project's formatting requirements and
resolve the failing CI lint check.

Co-authored-by: amtk3 <254821816+amtk3@users.noreply.github.com>
style: Reformat test_impersonated_credentials.py to fix black lint error
…4737746463131592670

style: Reformat test_impersonated_credentials.py to fix black lint error
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 10, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 10, 2026
@daniel-sanche daniel-sanche enabled auto-merge (squash) June 11, 2026 00:17
@parthea parthea self-assigned this Jun 11, 2026
@parthea parthea removed their assignment Jun 11, 2026
@daniel-sanche daniel-sanche merged commit 57269d5 into googleapis:main Jun 11, 2026
32 of 35 checks passed
sofisl added a commit that referenced this pull request Jun 11, 2026
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.19.0
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:234b9d1f2ddb057ed7ac6a38db0bf8163d839c65c6cf88ade52530cddebce59e
<details><summary>gapic-generator: v1.35.0</summary>

##
[v1.35.0](gapic-generator-v1.34.1...gapic-generator-v1.35.0)
(2026-06-11)

### Features

* setup.py matches prerelease versions (#17370)
([25b857e](25b857e1))

### Bug Fixes

* require protobuf 6.33.5 to address CVE-2026-0994 (#17349)
([6642263](66422636))

</details>


<details><summary>google-auth: v2.54.0</summary>

##
[v2.54.0](google-auth-v2.53.0...google-auth-v2.54.0)
(2026-06-11)

### Features

* implement regional access boundary support for standalone JWT and
async service accounts (#17025)
([35af616](35af6168))

### Bug Fixes

* configure mTLS for impersonated credentials (#17404)
([57269d5](57269d56))

* fail-fast on missing ECP config file to avoid 30s hang (#17377)
([e096127](e0961270))

* Rename the &#39;seed&#39; argument for setting an initial regional
access boundary for clarity (#17186)
([e5c8cf9](e5c8cf92))

* update incorrect urls in setup.py to point at monorepo vs splitrepo
(#17237)
([eaed04b](eaed04ba))

</details>


<details><summary>google-cloud-alloydb: v0.11.0</summary>

##
[v0.11.0](google-cloud-alloydb-v0.10.0...google-cloud-alloydb-v0.11.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17413)
([59fe7cf](59fe7cf8))

</details>


<details><summary>google-cloud-biglake: v0.5.0</summary>

##
[v0.5.0](google-cloud-biglake-v0.4.0...google-cloud-biglake-v0.5.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17431)
([2e75c78](2e75c78c))

</details>


<details><summary>google-cloud-ces: v0.7.0</summary>

##
[v0.7.0](google-cloud-ces-v0.6.0...google-cloud-ces-v0.7.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17413)
([59fe7cf](59fe7cf8))

</details>


<details><summary>google-cloud-confidentialcomputing: v0.11.0</summary>

##
[v0.11.0](google-cloud-confidentialcomputing-v0.10.0...google-cloud-confidentialcomputing-v0.11.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17413)
([59fe7cf](59fe7cf8))

</details>


<details><summary>google-cloud-modelarmor: v0.7.0</summary>

##
[v0.7.0](google-cloud-modelarmor-v0.6.0...google-cloud-modelarmor-v0.7.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17413)
([59fe7cf](59fe7cf8))

</details>


<details><summary>google-cloud-network-services: v0.10.0</summary>

##
[v0.10.0](google-cloud-network-services-v0.9.0...google-cloud-network-services-v0.10.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17431)
([2e75c78](2e75c78c))

</details>


<details><summary>google-cloud-oracledatabase: v0.6.0</summary>

##
[v0.6.0](google-cloud-oracledatabase-v0.5.0...google-cloud-oracledatabase-v0.6.0)
(2026-06-11)

### Features

* update API sources and regenerate (#17413)
([59fe7cf](59fe7cf8))

</details>


<details><summary>google-cloud-spanner: v3.68.0</summary>

##
[v3.68.0](google-cloud-spanner-v3.67.0...google-cloud-spanner-v3.68.0)
(2026-06-11)

### Features

* add asynchronous code snippets and minor cleanup changes (#17337)
([d6aaf61](d6aaf610))

### Performance Improvements

* optimize query result decoding (#17375)
([3f70b2f](3f70b2ff))

</details>


<details><summary>google-cloud-storage: v3.12.0</summary>

##
[v3.12.0](google-cloud-storage-v3.11.0...google-cloud-storage-v3.12.0)
(2026-06-11)

### Features

* full object checksum: implement rolling checksum and verification in
reads resumption strategy (#17262)
([2361ba6](2361ba6e))

* Enable full object checksum PR 1/3 : parse finalize_time and server
crc32c in async object stream (#17261)
([72c7a27](72c7a272))

* full object checksum: integrate full-object checksum in
AsyncMultiRangeDownloader (#17263)
([b6a85e4](b6a85e49))

</details>


<details><summary>google-developer-knowledge: v0.1.0</summary>

##
[v0.1.0](google-developer-knowledge-v0.0.0...google-developer-knowledge-v0.1.0)
(2026-06-11)

### Features

* add google-developer-knowledge (#17417)
([ca02afc](ca02afce))

</details>
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.

4 participants