-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(auth): Ensure new auth SDK versions are backwards compatible with previous SDKs to enable copying to G3 #17407
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
base: main
Are you sure you want to change the base?
Changes from all commits
6cd4f2b
01cd840
a96d509
92ea90e
46d5f2a
97ff318
f2f5074
403d450
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 | ||
|---|---|---|---|---|
|
|
@@ -33,15 +33,16 @@ | |||
| import logging | ||||
| from typing import Optional, TYPE_CHECKING | ||||
|
|
||||
|
|
||||
| from google.auth import _exponential_backoff | ||||
| from google.auth import _helpers | ||||
| from google.auth import _regional_access_boundary_utils | ||||
| from google.auth import credentials | ||||
| from google.auth import exceptions | ||||
| from google.auth import iam | ||||
| from google.auth import jwt | ||||
| from google.auth import metrics | ||||
| from google.auth import ( | ||||
| _exponential_backoff, | ||||
| _helpers, | ||||
| _regional_access_boundary_utils, | ||||
| credentials, | ||||
| exceptions, | ||||
| iam, | ||||
| jwt, | ||||
| metrics, | ||||
| ) | ||||
| from google.oauth2 import _client | ||||
|
|
||||
| if TYPE_CHECKING: # pragma: NO COVER | ||||
|
|
@@ -262,7 +263,12 @@ def __init__( | |||
| ): | ||||
| self._source_credentials._create_self_signed_jwt(None) | ||||
|
|
||||
| self._universe_domain = source_credentials.universe_domain | ||||
| universe_domain = getattr(source_credentials, "universe_domain", None) | ||||
| self._universe_domain = ( | ||||
| universe_domain | ||||
| if isinstance(universe_domain, str) | ||||
| else credentials.DEFAULT_UNIVERSE_DOMAIN | ||||
| ) | ||||
|
macastelaz marked this conversation as resolved.
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. This seems like it could be a pretty big behaviour change. Are you sure this is safe?
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. It should be safe (I know, famous last words): the base credential class already sets this same default (
Thoughts? |
||||
| self._target_principal = target_principal | ||||
| self._target_scopes = target_scopes | ||||
| self._delegates = delegates | ||||
|
|
@@ -352,7 +358,8 @@ def _perform_refresh_token(self, request): | |||
| ) | ||||
|
|
||||
| def _build_regional_access_boundary_lookup_url( | ||||
| self, request: "Optional[google.auth.transport.Request]" = None # noqa: F821 | ||||
| self, | ||||
| request: "Optional[google.auth.transport.Request]" = None, # noqa: F821 | ||||
| ): | ||||
| """Builds and returns the URL for the Regional Access Boundary lookup API. | ||||
|
|
||||
|
|
@@ -564,7 +571,7 @@ def __init__( | |||
|
|
||||
| if not isinstance(target_credentials, Credentials): | ||||
| raise exceptions.GoogleAuthError( | ||||
| "Provided Credential must be " "impersonated_credentials" | ||||
| "Provided Credential must be impersonated_credentials" | ||||
| ) | ||||
| self._target_credentials = target_credentials | ||||
| self._target_audience = target_audience | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,9 +20,7 @@ | |||||
| import re | ||||||
| import subprocess | ||||||
|
|
||||||
| from google.auth import _agent_identity_utils | ||||||
| from google.auth import environment_vars | ||||||
| from google.auth import exceptions | ||||||
| from google.auth import _agent_identity_utils, environment_vars, exceptions | ||||||
|
|
||||||
| CONTEXT_AWARE_METADATA_PATH = "~/.secureConnect/context_aware_metadata.json" | ||||||
|
|
||||||
|
|
@@ -453,7 +451,7 @@ def check_use_client_cert(): | |||||
|
|
||||||
| If GOOGLE_API_USE_CLIENT_CERTIFICATE is set to true or false, a corresponding | ||||||
| bool value will be returned. If the value is set to an unexpected string, it | ||||||
| will default to False. | ||||||
| will raise a ValueError. | ||||||
| If GOOGLE_API_USE_CLIENT_CERTIFICATE is unset, the value will be inferred | ||||||
| by reading a file pointed at by GOOGLE_API_CERTIFICATE_CONFIG, and verifying | ||||||
| it contains a "workload" section. If so, the function will return True, | ||||||
|
|
@@ -470,6 +468,11 @@ def check_use_client_cert(): | |||||
|
|
||||||
| # Check if the value of GOOGLE_API_USE_CLIENT_CERTIFICATE is set. | ||||||
| if use_client_cert: | ||||||
| if use_client_cert.lower() not in ("true", "false"): | ||||||
| raise ValueError( | ||||||
| "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be" | ||||||
| " either `true` or `false`" | ||||||
| ) | ||||||
|
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. I don't think we should be reverting this kind of behaviour. It was an explicit decision to return False instead of raise an exception here
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. Do you by chance have any additional context you could share on the original decision to return False here? From my view point, it feels like a security risk to not fail fast here. E.g. if a user sets this to FWIW, there are internal tests for gapic generated clients that are asserting an error is raised so if we do stick with returning false, we'll likely need to update a lot of older APIs, etc. FWIW, we currently have a discrepancy in Line 310 in 384724c
Line 210 in 384724c
|
||||||
| return use_client_cert.lower() == "true" | ||||||
| else: | ||||||
| # Check if the value of GOOGLE_API_CERTIFICATE_CONFIG is set. | ||||||
|
|
||||||
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.
Is this to support subclasses? (If so, maybe add a comment?)
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.
Added a comment