mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 03:25:04 -04:00
Improve error checking for OIDC/SAML mapping providers (#8774)
Checks that the localpart returned by mapping providers for SAML and OIDC are valid before registering new users. Extends the OIDC tests for existing users and invalid data.
This commit is contained in:
parent
53a6f5ddf0
commit
79bfe966e0
7 changed files with 137 additions and 29 deletions
|
@ -31,6 +31,7 @@ from synapse.http.site import SynapseRequest
|
|||
from synapse.module_api import ModuleApi
|
||||
from synapse.types import (
|
||||
UserID,
|
||||
contains_invalid_mxid_characters,
|
||||
map_username_to_mxid_localpart,
|
||||
mxid_localpart_allowed_characters,
|
||||
)
|
||||
|
@ -318,6 +319,11 @@ class SamlHandler(BaseHandler):
|
|||
"Unable to generate a Matrix ID from the SAML response"
|
||||
)
|
||||
|
||||
# Since the localpart is provided via a potentially untrusted module,
|
||||
# ensure the MXID is valid before registering.
|
||||
if contains_invalid_mxid_characters(localpart):
|
||||
raise MappingException("localpart is invalid: %s" % (localpart,))
|
||||
|
||||
logger.info("Mapped SAML user to local part %s", localpart)
|
||||
registered_user_id = await self._registration_handler.register_user(
|
||||
localpart=localpart,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue