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

Commit

Permalink
Enable refreshable tokens on the admin registration endpoint (#16642)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Wright <[email protected]>
  • Loading branch information
Charles Wright authored Nov 22, 2023
1 parent f2430b1 commit 1a5f9bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit 1a5f9bb

Please sign in to comment.