mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 19:45:03 -04:00
SSO: redirect to public URL before setting cookies (#9436)
... otherwise, we don't get the cookie back.
This commit is contained in:
parent
e53f11bd62
commit
15090de850
7 changed files with 130 additions and 28 deletions
|
@ -542,13 +542,30 @@ class RestHelper:
|
|||
if client_redirect_url:
|
||||
params["redirectUrl"] = client_redirect_url
|
||||
|
||||
# hit the redirect url (which will issue a cookie and state)
|
||||
# hit the redirect url (which should redirect back to the redirect url. This
|
||||
# is the easiest way of figuring out what the Host header ought to be set to
|
||||
# to keep Synapse happy.
|
||||
channel = make_request(
|
||||
self.hs.get_reactor(),
|
||||
self.site,
|
||||
"GET",
|
||||
"/_matrix/client/r0/login/sso/redirect?" + urllib.parse.urlencode(params),
|
||||
)
|
||||
assert channel.code == 302
|
||||
|
||||
# hit the redirect url again with the right Host header, which should now issue
|
||||
# a cookie and redirect to the SSO provider.
|
||||
location = channel.headers.getRawHeaders("Location")[0]
|
||||
parts = urllib.parse.urlsplit(location)
|
||||
channel = make_request(
|
||||
self.hs.get_reactor(),
|
||||
self.site,
|
||||
"GET",
|
||||
urllib.parse.urlunsplit(("", "") + parts[2:]),
|
||||
custom_headers=[
|
||||
("Host", parts[1]),
|
||||
],
|
||||
)
|
||||
|
||||
assert channel.code == 302
|
||||
channel.extract_cookies(cookies)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue