Add additional validation for the admin register endpoint. (#8837)

Raise a proper 400 error if the `mac` field is missing.
This commit is contained in:
David Florness 2020-12-02 10:01:15 -05:00 committed by GitHub
parent e41720d85f
commit c4675e1b24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -420,6 +420,9 @@ class UserRegisterServlet(RestServlet):
if user_type is not None and user_type not in UserTypes.ALL_USER_TYPES:
raise SynapseError(400, "Invalid user type")
if "mac" not in body:
raise SynapseError(400, "mac must be specified", errcode=Codes.BAD_JSON)
got_mac = body["mac"]
want_mac_builder = hmac.new(