Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Raise 400 error for /_synapse/admin/v1/register on missing mac
Browse files Browse the repository at this point in the history
Signed-off-by: David Florness <david@florness.com>
  • Loading branch information
edwargix committed Dec 1, 2020
1 parent 4d94965 commit 052cf9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/8837.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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.
3 changes: 3 additions & 0 deletions synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ async def on_POST(self, request):
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(
Expand Down

0 comments on commit 052cf9c

Please sign in to comment.