Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Support UI Authentication for OpenID Connect accounts #7457

Merged
merged 7 commits into from
May 15, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix mypy error.
clokep committed May 8, 2020

Verified

This commit was signed with the committer’s verified signature.
lucasssvaz Lucas Saavedra Vaz
commit 738111a111822d766f7cfcdb822d9887c4050dd4
19 changes: 8 additions & 11 deletions synapse/handlers/oidc_handler.py
Original file line number Diff line number Diff line change
@@ -783,21 +783,21 @@ def _verify_oidc_session_token(
client_redirect_url = self._get_value_from_macaroon(
macaroon, "client_redirect_url"
)
ui_auth_session_id = self._get_value_from_macaroon(
macaroon, "ui_auth_session_id", required=False
)
try:
ui_auth_session_id = self._get_value_from_macaroon(
macaroon, "ui_auth_session_id"
) # type: Optional[str]
except ValueError:
ui_auth_session_id = None

return nonce, client_redirect_url, ui_auth_session_id

def _get_value_from_macaroon(
self, macaroon: pymacaroons.Macaroon, key: str, required: bool = True
) -> Optional[str]:
def _get_value_from_macaroon(self, macaroon: pymacaroons.Macaroon, key: str) -> str:
"""Extracts a caveat value from a macaroon token.
Args:
macaroon: the token
key: the key of the caveat to extract
required: Whether to raise an exception if the caveat is not found.
Returns:
The extracted value
@@ -809,10 +809,7 @@ def _get_value_from_macaroon(
for caveat in macaroon.caveats:
if caveat.caveat_id.startswith(prefix):
return caveat.caveat_id[len(prefix) :]

if required:
raise Exception("No %s caveat in macaroon" % (key,))
return None
raise ValueError("No %s caveat in macaroon" % (key,))

def _verify_expiry(self, caveat: str) -> bool:
prefix = "time < "