Skip to content
Snippets Groups Projects
Unverified Commit c4675e1b authored by David Florness's avatar David Florness Committed by GitHub
Browse files

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

Raise a proper 400 error if the `mac` field is missing.
parent e41720d8
No related branches found
No related tags found
No related merge requests found
Fix a long standing bug in the register admin endpoint (`/_synapse/admin/v1/register`) when the `mac` field was not provided. The endpoint now properly returns a 400 error. Contributed by @edwargix.
...@@ -420,6 +420,9 @@ class UserRegisterServlet(RestServlet): ...@@ -420,6 +420,9 @@ class UserRegisterServlet(RestServlet):
if user_type is not None and user_type not in UserTypes.ALL_USER_TYPES: if user_type is not None and user_type not in UserTypes.ALL_USER_TYPES:
raise SynapseError(400, "Invalid user type") 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"] got_mac = body["mac"]
want_mac_builder = hmac.new( want_mac_builder = hmac.new(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment