mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-09 19:02:15 -04:00
Add the ability to enable/disable registrations when in the OIDC flow (#14978)
Signed-off-by: Warren Bailey <warren@warrenbailey.net>
This commit is contained in:
parent
9228ae633f
commit
a3bad89d57
6 changed files with 44 additions and 3 deletions
|
@ -922,7 +922,7 @@ class OidcHandlerTestCase(HomeserverTestCase):
|
|||
auth_provider_session_id=None,
|
||||
)
|
||||
|
||||
@override_config({"oidc_config": DEFAULT_CONFIG})
|
||||
@override_config({"oidc_config": {**DEFAULT_CONFIG, "enable_registration": True}})
|
||||
def test_map_userinfo_to_user(self) -> None:
|
||||
"""Ensure that mapping the userinfo returned from a provider to an MXID works properly."""
|
||||
userinfo: dict = {
|
||||
|
@ -975,6 +975,21 @@ class OidcHandlerTestCase(HomeserverTestCase):
|
|||
"Mapping provider does not support de-duplicating Matrix IDs",
|
||||
)
|
||||
|
||||
@override_config({"oidc_config": {**DEFAULT_CONFIG, "enable_registration": False}})
|
||||
def test_map_userinfo_to_user_does_not_register_new_user(self) -> None:
|
||||
"""Ensures new users are not registered if the enabled registration flag is disabled."""
|
||||
userinfo: dict = {
|
||||
"sub": "test_user",
|
||||
"username": "test_user",
|
||||
}
|
||||
request, _ = self.start_authorization(userinfo)
|
||||
self.get_success(self.handler.handle_oidc_callback(request))
|
||||
self.complete_sso_login.assert_not_called()
|
||||
self.assertRenderedError(
|
||||
"mapping_error",
|
||||
"User does not exist and registrations are disabled",
|
||||
)
|
||||
|
||||
@override_config({"oidc_config": {**DEFAULT_CONFIG, "allow_existing_users": True}})
|
||||
def test_map_userinfo_to_existing_user(self) -> None:
|
||||
"""Existing users can log in with OpenID Connect when allow_existing_users is True."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue