Skip to content
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

feat: making iam endpoint universe-aware #1604

Merged
merged 11 commits into from
Oct 19, 2024
5 changes: 4 additions & 1 deletion google/auth/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
http_client.GATEWAY_TIMEOUT,
}

_DEFAULT_UNIVERSE_DOMAIN = ["googleapis.com"]
TimurSadykov marked this conversation as resolved.
Show resolved Hide resolved

_IAM_SCOPE = ["https://www.googleapis.com/auth/iam"]

_IAM_SCOPE = ["https://www.googleapis.com/auth/iam"]

_IAM_ENDPOINT = (
"https://iamcredentials.googleapis.com/v1/projects/-"
"https://iamcredentials.{}/v1/projects/-"
+ "/serviceAccounts/{}:generateAccessToken"
)

Expand Down
5 changes: 5 additions & 0 deletions google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def __init__(
and self._source_credentials._always_use_jwt_access
):
self._source_credentials._create_self_signed_jwt(None)
if (self.universe_domain != self._source_credentials.universe_domain):
TimurSadykov marked this conversation as resolved.
Show resolved Hide resolved
self._universe_domain = source_credentials.universe_domain
self._target_principal = target_principal
self._target_scopes = target_scopes
self._delegates = delegates
Expand All @@ -227,6 +229,9 @@ def __init__(
self.expiry = _helpers.utcnow()
self._quota_project_id = quota_project_id
self._iam_endpoint_override = iam_endpoint_override

if (self._iam_endpoint_override == None):
self._iam_endpoint_override = iam._IAM_ENDPOINT.format(self.universe_domain, self._target_principal)
TimurSadykov marked this conversation as resolved.
Show resolved Hide resolved
self._cred_file_path = None

def _metric_header_for_usage(self):
Expand Down