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

Allow OIDC cookies to work on non-root public baseurls #9726

Merged
merged 6 commits into from
Apr 23, 2021
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
15 changes: 10 additions & 5 deletions synapse/handlers/oidc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,15 @@ def __init__(
# TODO: This is pretty much a hack to get the path specified by public_baseurl.
# It'd probably be nicer to have a config option that lets you specify a custom
# path, which we'd then use here.
self._callback_path_prefix = urlparse(hs.config.public_baseurl).path
if self._callback_path_prefix.endswith("/"):
self._callback_path_prefix = self._callback_path_prefix[:-1]
public_baseurl_path = urlparse(hs.config.public_baseurl).path
if public_baseurl_path.endswith("/"):
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
public_baseurl_path = public_baseurl_path[:-1]

# Calculate the prefix for OIDC callback paths based on the public_baseurl.
# We'll insert this into the Path= parameter of any session cookies we set.
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
self._callback_path_prefix = (
public_baseurl_path.encode("utf-8") + b"/_synapse/client/oidc"
)

self._oidc_attribute_requirements = provider.attribute_requirements
self._scopes = provider.scopes
Expand Down Expand Up @@ -793,8 +799,7 @@ async def handle_redirect_request(
% (
cookie_name,
cookie.encode("utf-8"),
self._callback_path_prefix.encode("utf-8")
+ b"/_synapse/client/oidc",
self._callback_path_prefix,
options,
)
)
Expand Down