Skip to content

Commit

Permalink
add universe_domain parameter for the iam request
Browse files Browse the repository at this point in the history
  • Loading branch information
TimurSadykov committed Oct 14, 2024
1 parent ca31a66 commit 17d1d1b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@


def _make_iam_token_request(
request, principal, headers, body, iam_endpoint_override=None
request, principal, headers, body, universe_domain, iam_endpoint_override=None
):
"""Makes a request to the Google Cloud IAM service for an access token.
Args:
Expand All @@ -67,7 +67,7 @@ def _make_iam_token_request(
`iamcredentials.googleapis.com` is not enabled or the
`Service Account Token Creator` is not assigned
"""
iam_endpoint = iam_endpoint_override or iam._IAM_ENDPOINT.format(principal)
iam_endpoint = iam_endpoint_override or iam._IAM_ENDPOINT.format(universe_domain, principal)

body = json.dumps(body).encode("utf-8")

Expand Down Expand Up @@ -229,9 +229,6 @@ 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)
self._cred_file_path = None

def _metric_header_for_usage(self):
Expand Down Expand Up @@ -276,6 +273,7 @@ def _update_token(self, request):
principal=self._target_principal,
headers=headers,
body=body,
universe_domain=self.universe_domain,
iam_endpoint_override=self._iam_endpoint_override,
)

Expand All @@ -285,7 +283,7 @@ def get_iam_sign_endpoint(self):
def sign_bytes(self, message):
from google.auth.transport.requests import AuthorizedSession

iam_sign_endpoint = get_iam_sign_endpoint(self)
iam_sign_endpoint = self.get_iam_sign_endpoint(self)

body = {
"payload": base64.b64encode(message).decode("utf-8"),
Expand Down

0 comments on commit 17d1d1b

Please sign in to comment.