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

Commit c4675e1

Browse files
authored
Add additional validation for the admin register endpoint. (#8837)
Raise a proper 400 error if the `mac` field is missing.
1 parent e41720d commit c4675e1

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

changelog.d/8837.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

synapse/rest/admin/users.py

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ async def on_POST(self, request):
420420
if user_type is not None and user_type not in UserTypes.ALL_USER_TYPES:
421421
raise SynapseError(400, "Invalid user type")
422422

423+
if "mac" not in body:
424+
raise SynapseError(400, "mac must be specified", errcode=Codes.BAD_JSON)
425+
423426
got_mac = body["mac"]
424427

425428
want_mac_builder = hmac.new(

0 commit comments

Comments
 (0)