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

Commit eb82002

Browse files
committed
Save the SSO user ID for later comparison to the auth user ID.
1 parent f8ce002 commit eb82002

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

synapse/handlers/auth.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ def complete_sso_ui_auth(
10491049
registered_user_id: str,
10501050
session_id: str,
10511051
request: SynapseRequest,
1052-
requester: Requester,
10531052
):
10541053
"""Having figured out a mxid for this user, complete the HTTP request
10551054
@@ -1059,18 +1058,15 @@ def complete_sso_ui_auth(
10591058
client_redirect_url: The URL to which to redirect the user at the end of the
10601059
process.
10611060
"""
1062-
# If the user ID of the SAML session does not match the user from the
1063-
# request, something went wrong.
1064-
if registered_user_id != requester.user.to_string():
1065-
raise SynapseError(403, "SAML user does not match requester.")
1066-
10671061
# Mark the stage of the authentication as successful.
10681062
sess = self._get_session_info(session_id)
10691063
if "creds" not in sess:
10701064
sess["creds"] = {}
10711065
creds = sess["creds"]
10721066

1073-
creds[LoginType.SSO] = True
1067+
# Save the user who authenticated with SSO, this will be used to ensure
1068+
# that the account be modified is also the person who logged in.
1069+
creds[LoginType.SSO] = registered_user_id
10741070
self._save_session(sess)
10751071

10761072
# Render the HTML and return.

synapse/handlers/saml_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ async def handle_saml_response(self, request):
145145

146146
# Complete the interactive auth session or the login.
147147
if current_session and current_session.ui_auth_session_id:
148-
requester = await self._auth.get_user_by_req(request)
149148
self._auth_handler.complete_sso_ui_auth(
150-
user_id, current_session.ui_auth_session_id, request, requester
149+
user_id, current_session.ui_auth_session_id, request
151150
)
152151

153152
else:

0 commit comments

Comments
 (0)