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

Commit

Permalink
fiddle with cookie options to pacify Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Feb 16, 2021
1 parent 3b5ac3a commit 1102094
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions synapse/handlers/oidc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,17 +710,18 @@ async def handle_redirect_request(
# and one with no SameSite, in the hope that at least one of them will get
# back to us.
#
# Secure is necessary for SameSite=None
# Secure is necessary for SameSite=None (and, empirically, also breaks things
# on iOS 12.)
#
# we have to build the cookie by hand rather than calling request.addCookie
# to work around https://twistedmatrix.com/trac/ticket/10088
#
for cookie_name, options in [
(SESSION_COOKIE_NAME, b"; SameSite=None"),
(SESSION_COOKIE_NAME, b"; Secure; SameSite=None"),
(SESSION_COOKIE_NAME_IOS_HACK, b""),
]:
request.cookies.append(
b"%s=%s; Path=/_synapse/client/oidc; Max-Age=3600; HttpOnly; Secure%s"
b"%s=%s; Path=/_synapse/client/oidc; Max-Age=3600; HttpOnly%s"
% (cookie_name, cookie.encode("utf-8"), options)
)

Expand Down

0 comments on commit 1102094

Please sign in to comment.