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

Commit

Permalink
Disable /register/available if registration is disabled (#6082)
Browse files Browse the repository at this point in the history
Fixes #6066

This register endpoint should be disabled if registration is disabled, otherwise we're giving anyone the ability to check if a username exists on a server when we don't need to be.

Error code is 403 (Forbidden) as that's the same returned by /register when registration is disabled.
  • Loading branch information
anoadragon453 authored and richvdh committed Sep 23, 2019
1 parent 1c9fead commit 1b519e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/6082.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Return 403 on `/register/available` if registration has been disabled.
5 changes: 5 additions & 0 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ def __init__(self, hs):

@defer.inlineCallbacks
def on_GET(self, request):
if not self.hs.config.enable_registration:
raise SynapseError(
403, "Registration has been disabled", errcode=Codes.FORBIDDEN
)

ip = self.hs.get_ip_from_request(request)
with self.ratelimiter.ratelimit(ip) as wait_deferred:
yield wait_deferred
Expand Down

0 comments on commit 1b519e0

Please sign in to comment.