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

Enable refreshable tokens on the admin registration endpoint #16642

Merged
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/16642.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable refreshable tokens on the admin registration endpoint.
10 changes: 9 additions & 1 deletion synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
if not hmac.compare_digest(want_mac.encode("ascii"), got_mac.encode("ascii")):
raise SynapseError(HTTPStatus.FORBIDDEN, "HMAC incorrect")

should_issue_refresh_token = body.get("refresh_token", False)
if not isinstance(should_issue_refresh_token, bool):
raise SynapseError(
HTTPStatus.BAD_REQUEST, "refresh_token must be a boolean"
)

# Reuse the parts of RegisterRestServlet to reduce code duplication
from synapse.rest.client.register import RegisterRestServlet

Expand All @@ -645,7 +651,9 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
approved=True,
)

result = await register._create_registration_details(user_id, body)
result = await register._create_registration_details(
user_id, body, should_issue_refresh_token=should_issue_refresh_token
)
return HTTPStatus.OK, result


Expand Down
Loading