Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Oct 23, 2024
1 parent 1b2d18f commit b31effb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
12 changes: 7 additions & 5 deletions google/auth/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@
)

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

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


Expand Down Expand Up @@ -88,9 +90,9 @@ def _make_signing_request(self, message):
message = _helpers.to_bytes(message)

method = "POST"
url = _IAM_SIGN_ENDPOINT.replace(credentials.DEFAULT_UNIVERSE_DOMAIN, self._credentials.universe_domain).format(
self._service_account_email
)
url = _IAM_SIGN_ENDPOINT.replace(
credentials.DEFAULT_UNIVERSE_DOMAIN, self._credentials.universe_domain
).format(self._service_account_email)
headers = {"Content-Type": "application/json"}
body = json.dumps(
{"payload": base64.b64encode(message).decode("utf-8")}
Expand Down
17 changes: 10 additions & 7 deletions google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ 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.replace(credentials.DEFAULT_UNIVERSE_DOMAIN, universe_domain).format(principal)
iam_endpoint = iam_endpoint_override or iam._IAM_ENDPOINT.replace(
credentials.DEFAULT_UNIVERSE_DOMAIN, universe_domain
).format(principal)

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

Expand Down Expand Up @@ -280,9 +282,9 @@ def _update_token(self, request):
def sign_bytes(self, message):
from google.auth.transport.requests import AuthorizedSession

iam_sign_endpoint = iam._IAM_SIGN_ENDPOINT.replace(credentials.DEFAULT_UNIVERSE_DOMAIN, self.universe_domain).format(
self._target_principal
)
iam_sign_endpoint = iam._IAM_SIGN_ENDPOINT.replace(
credentials.DEFAULT_UNIVERSE_DOMAIN, self.universe_domain
).format(self._target_principal)

body = {
"payload": base64.b64encode(message).decode("utf-8"),
Expand Down Expand Up @@ -432,9 +434,10 @@ def with_quota_project(self, quota_project_id):
def refresh(self, request):
from google.auth.transport.requests import AuthorizedSession

iam_sign_endpoint = iam._IAM_IDTOKEN_ENDPOINT.replace(credentials.DEFAULT_UNIVERSE_DOMAIN, self._target_credentials.universe_domain).format(
self._target_credentials.signer_email,
)
iam_sign_endpoint = iam._IAM_IDTOKEN_ENDPOINT.replace(
credentials.DEFAULT_UNIVERSE_DOMAIN,
self._target_credentials.universe_domain,
).format(self._target_credentials.signer_email)

body = {
"audience": self._target_audience,
Expand Down

0 comments on commit b31effb

Please sign in to comment.