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

Commit 50c92f3

Browse files
authored
Carry IdP Session IDs through user-mapping sessions. (#13839)
Since #11482, we're saving sessions IDs from upstream IdPs, but we've been losing them when the user goes through a user mapping session on account registration.
1 parent a95ce6d commit 50c92f3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

changelog.d/13839.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Carry IdP Session IDs through user-mapping sessions.

synapse/handlers/sso.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ class UsernameMappingSession:
147147
# A unique identifier for this SSO provider, e.g. "oidc" or "saml".
148148
auth_provider_id: str
149149

150+
# An optional session ID from the IdP.
151+
auth_provider_session_id: Optional[str]
152+
150153
# user ID on the IdP server
151154
remote_user_id: str
152155

@@ -464,6 +467,7 @@ async def complete_sso_login_request(
464467
client_redirect_url,
465468
next_step_url,
466469
extra_login_attributes,
470+
auth_provider_session_id,
467471
)
468472

469473
user_id = await self._register_mapped_user(
@@ -585,6 +589,7 @@ async def _redirect_to_next_new_user_step(
585589
client_redirect_url: str,
586590
next_step_url: bytes,
587591
extra_login_attributes: Optional[JsonDict],
592+
auth_provider_session_id: Optional[str],
588593
) -> NoReturn:
589594
"""Creates a UsernameMappingSession and redirects the browser
590595
@@ -607,6 +612,8 @@ async def _redirect_to_next_new_user_step(
607612
extra_login_attributes: An optional dictionary of extra
608613
attributes to be provided to the client in the login response.
609614
615+
auth_provider_session_id: An optional session ID from the IdP.
616+
610617
Raises:
611618
RedirectException
612619
"""
@@ -615,6 +622,7 @@ async def _redirect_to_next_new_user_step(
615622
now = self._clock.time_msec()
616623
session = UsernameMappingSession(
617624
auth_provider_id=auth_provider_id,
625+
auth_provider_session_id=auth_provider_session_id,
618626
remote_user_id=remote_user_id,
619627
display_name=attributes.display_name,
620628
emails=attributes.emails,
@@ -968,6 +976,7 @@ async def register_sso_user(self, request: Request, session_id: str) -> None:
968976
session.client_redirect_url,
969977
session.extra_login_attributes,
970978
new_user=True,
979+
auth_provider_session_id=session.auth_provider_session_id,
971980
)
972981

973982
def _expire_old_sessions(self) -> None:

0 commit comments

Comments
 (0)