-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix SSO on workers #9271
Fix SSO on workers #9271
Changes from all commits
a83decf
3fb8c08
64f5b6c
e897ff1
d500d1c
bf83a20
ca42754
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix single-sign-on when the endpoints are routed to synapse workers. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,6 @@ expressions: | |
^/_matrix/client/(api/v1|r0|unstable)/joined_groups$ | ||
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups$ | ||
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups/ | ||
^/_synapse/client/password_reset/email/submit_token$ | ||
|
||
# Registration/login requests | ||
^/_matrix/client/(api/v1|r0|unstable)/login$ | ||
|
@@ -256,25 +255,28 @@ Additionally, the following endpoints should be included if Synapse is configure | |
to use SSO (you only need to include the ones for whichever SSO provider you're | ||
using): | ||
|
||
# for all SSO providers | ||
^/_matrix/client/(api/v1|r0|unstable)/login/sso/redirect | ||
^/_synapse/client/pick_idp$ | ||
^/_synapse/client/pick_username | ||
^/_synapse/client/sso_register$ | ||
|
||
# OpenID Connect requests. | ||
^/_matrix/client/(api/v1|r0|unstable)/login/sso/redirect$ | ||
^/_synapse/oidc/callback$ | ||
|
||
# SAML requests. | ||
^/_matrix/client/(api/v1|r0|unstable)/login/sso/redirect$ | ||
^/_matrix/saml2/authn_response$ | ||
|
||
# CAS requests. | ||
^/_matrix/client/(api/v1|r0|unstable)/login/(cas|sso)/redirect$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this one was slightly different in that it has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeahh, I'm hoping that's old enough that basically nobody will encounter it. |
||
^/_matrix/client/(api/v1|r0|unstable)/login/cas/ticket$ | ||
|
||
Note that a HTTP listener with `client` and `federation` resources must be | ||
configured in the `worker_listeners` option in the worker config. | ||
|
||
Ensure that all SSO logins go to a single process (usually the main process). | ||
Ensure that all SSO logins go to a single process. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably true for the UI auth endpoints too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it is? afaik nothing is tracked in-memory for UIA (at least for CAS/OIDC; SAML has #7530) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, the username mapping sessions and extra attributes only matter on login, not during UI auth. OK. |
||
For multiple workers not handling the SSO endpoints properly, see | ||
[#7530](https://github.com/matrix-org/synapse/issues/7530). | ||
|
||
Note that a HTTP listener with `client` and `federation` resources must be | ||
configured in the `worker_listeners` option in the worker config. | ||
|
||
#### Load balancing | ||
|
||
It is possible to run multiple instances of this worker app, with incoming requests | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,6 +443,26 @@ def f(txn): | |
|
||
return await self.db_pool.runInteraction("get_users_by_id_case_insensitive", f) | ||
|
||
async def record_user_external_id( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is moving from |
||
self, auth_provider: str, external_id: str, user_id: str | ||
) -> None: | ||
"""Record a mapping from an external user id to a mxid | ||
|
||
Args: | ||
auth_provider: identifier for the remote auth provider | ||
external_id: id on that system | ||
user_id: complete mxid that it is mapped to | ||
""" | ||
await self.db_pool.simple_insert( | ||
table="user_external_ids", | ||
values={ | ||
"auth_provider": auth_provider, | ||
"external_id": external_id, | ||
"user_id": user_id, | ||
}, | ||
desc="record_user_external_id", | ||
) | ||
|
||
async def get_user_by_external_id( | ||
self, auth_provider: str, external_id: str | ||
) -> Optional[str]: | ||
|
@@ -1371,26 +1391,6 @@ def _register_user( | |
|
||
self._invalidate_cache_and_stream(txn, self.get_user_by_id, (user_id,)) | ||
|
||
async def record_user_external_id( | ||
self, auth_provider: str, external_id: str, user_id: str | ||
) -> None: | ||
"""Record a mapping from an external user id to a mxid | ||
|
||
Args: | ||
auth_provider: identifier for the remote auth provider | ||
external_id: id on that system | ||
user_id: complete mxid that it is mapped to | ||
""" | ||
await self.db_pool.simple_insert( | ||
table="user_external_ids", | ||
values={ | ||
"auth_provider": auth_provider, | ||
"external_id": external_id, | ||
"user_id": user_id, | ||
}, | ||
desc="record_user_external_id", | ||
) | ||
|
||
async def user_set_password_hash( | ||
self, user_id: str, password_hash: Optional[str] | ||
) -> None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tangential, but we may as well fix it while we're here.
This line was added in #8227. AFAICT, it has never worked on a worker.