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

[uss_qualifier] Fix non-cached sub information #384

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions monitoring/monitorlib/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ def issue_token(self, intended_audience: str, scopes: List[str]) -> str:
)
return response.json()["access_token"]

def get_sub(self) -> Optional[str]:
"""directly return the configured `sub` value"""
return self._sub


class _SessionIssuer:
"""Helper for issuing tokens using a pre-configured Google session."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def subscriber(self) -> str:
# sub might be none because no authentication has happened yet:
# we force one using the client identify audience and scopes

# Do an initial token request so that adapter.get_sub() will return something
token = self._adapter.issue_token(
intended_audience=self.specification.whoami_audience,
scopes=[self.specification.whoami_scope],
# Trigger a caching initial token request so that adapter.get_sub() will return something
headers = self._adapter.get_headers(
f"https://{self.specification.whoami_audience}",
[self.specification.whoami_scope],
)

sub = self._adapter.get_sub()
Expand All @@ -65,7 +65,7 @@ def subscriber(self) -> str:
raise ValueError(
f"subscriber is None, meaning `sub` claim was not found in payload of token, "
f"using {type(self._adapter).__name__} requesting {self.specification.whoami_scope} scope "
f"for {self.specification.whoami_audience} audience: {token}"
f"for {self.specification.whoami_audience} audience: {headers['Authorization'][len('Bearer: '):]}"
)

return sub
Loading