Skip to content

Commit

Permalink
fix: validate email absence when generating id token
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed May 2, 2024
1 parent 2a6d49a commit 9971411
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gcp_pilot/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,15 @@ def encode_jwt(self, payload: dict, service_account_email: str | None) -> str:

@friendly_http_error
def generate_id_token(self, audience: str, service_account_email: str | None = None) -> str:
email = service_account_email or self.service_account_email
if not email:
raise ValueError(
"You must either provide service_account_email or set GCP_SERVICE_ACCOUNT for impersonation."
)

response = self.client.generate_id_token(
name=self.client.service_account_path(
service_account=service_account_email or self.service_account_email,
service_account=email,
project="-",
),
audience=audience,
Expand Down

0 comments on commit 9971411

Please sign in to comment.