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

Raise 400 error for /_synapse/admin/v1/register on missing mac #8837

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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