Repository navigation
feat(auth): support bound access and ID tokens for GKE #18594
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |||||||
| import inspect | ||||||||
| import logging | ||||||||
| import time | ||||||||
| import urllib.parse | ||||||||
| import warnings | ||||||||
| from contextlib import asynccontextmanager | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly import
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive: |
||||||||
| from typing import TYPE_CHECKING, Mapping, Optional, Union | ||||||||
|
|
@@ -44,11 +43,6 @@ | |||||||
| ClientTimeout = None | ||||||||
|
|
||||||||
| _LOGGER = logging.getLogger(__name__) | ||||||||
| _MTLS_URL_PREFIXES = [ | ||||||||
| "mtls.googleapis.com", | ||||||||
| "mtls.sandbox.googleapis.com", | ||||||||
| "p.googleapis.com", | ||||||||
| ] | ||||||||
|
|
||||||||
| # Tracks the internal aiohttp installation and usage | ||||||||
| try: | ||||||||
|
|
@@ -482,13 +476,9 @@ async def request( | |||||||
| async def _recover_auth_state(): | ||||||||
| is_mtls_endpoint = False | ||||||||
| if self._is_mtls: | ||||||||
| hostname = urllib.parse.urlsplit(url).hostname | ||||||||
| if hostname: | ||||||||
| is_mtls_endpoint = any( | ||||||||
| hostname == prefix | ||||||||
| or hostname.endswith("." + prefix) | ||||||||
| for prefix in _MTLS_URL_PREFIXES | ||||||||
| ) | ||||||||
| is_mtls_endpoint = ( | ||||||||
| google.auth.transport._mtls_helper.is_mtls_endpoint(url) | ||||||||
| ) | ||||||||
|
Comment on lines
+479
to
+481
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rejecting the suggestion: Keeping |
||||||||
| # Snapshot the stale certificate state BEFORE acquiring the lock. | ||||||||
| # This represents the cert that caused the 401 rejection. | ||||||||
| if is_mtls_endpoint: | ||||||||
|
|
||||||||
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.
Pass
cert_bytesinstead ofraw_bytestoparse_certificate. Sincecert_byteshas already been cleaned of non-certificate blocks (like private keys or bag attributes) and validated, parsing it directly is safer and avoids redundant regex parsing insideparse_certificate.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.
Rejecting the suggestion. Keeping
raw_byteshere is intentional:cert_bytesis built from regex matches of complete PEM blocks and strips out any trailing block missing anENDmarker, so passingraw_bytesis required forparse_certificateto detect truncated certificate chains.