Skip to content

Commit

Permalink
Return 404 if not enabled instead of not loading the servlet
Browse files Browse the repository at this point in the history
  • Loading branch information
hughns committed Sep 20, 2022
1 parent 087ff04 commit 7287e36
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions synapse/rest/client/login_token_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ def __init__(self, hs: "HomeServer"):
self.server_name = hs.config.server.server_name
self.macaroon_gen = hs.get_macaroon_generator()
self.auth_handler = hs.get_auth_handler()
self.enabled = hs.config.experimental.msc3882_enabled
self.token_timeout = hs.config.experimental.msc3882_token_timeout
self.ui_auth = hs.config.experimental.msc3882_ui_auth

@interactive_auth_handler
async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
if not self.enabled:
return (404, {"errcode": "M_NOT_FOUND", "error": "Not found"})

requester = await self.auth.get_user_by_req(request)
body = parse_json_object_from_request(request)

Expand All @@ -80,7 +84,6 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
duration_in_ms=self.token_timeout,
)


return (
200,
{
Expand All @@ -91,5 +94,4 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:


def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
if hs.config.experimental.msc3882_enabled:
LoginTokenRequestServlet(hs).register(http_server)
LoginTokenRequestServlet(hs).register(http_server)

0 comments on commit 7287e36

Please sign in to comment.