diff options
author | ReidAnderson <rbarryanderson@gmail.com> | 2019-05-20 05:20:08 -0500 |
---|---|---|
committer | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-05-20 11:20:08 +0100 |
commit | 3787133c9e3fcf0e9b85700418bf03c48ec86ab3 (patch) | |
tree | 5142e89481b5cb89354337cb2f70e0ad7a72842f /synapse/handlers/register.py | |
parent | fix mapping of return values for get_or_register_3pid_guest (#5177) (diff) | |
download | synapse-3787133c9e3fcf0e9b85700418bf03c48ec86ab3.tar.xz |
Limit UserIds to a length that fits in a state key (#5198)
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r-- | synapse/handlers/register.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index a51d11a257..e83ee24f10 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -19,7 +19,7 @@ import logging from twisted.internet import defer from synapse import types -from synapse.api.constants import LoginType +from synapse.api.constants import MAX_USERID_LENGTH, LoginType from synapse.api.errors import ( AuthError, Codes, @@ -123,6 +123,15 @@ class RegistrationHandler(BaseHandler): self.check_user_id_not_appservice_exclusive(user_id) + if len(user_id) > MAX_USERID_LENGTH: + raise SynapseError( + 400, + "User ID may not be longer than %s characters" % ( + MAX_USERID_LENGTH, + ), + Codes.INVALID_USERNAME + ) + users = yield self.store.get_users_by_id_case_insensitive(user_id) if users: if not guest_access_token: |