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

Commit 1b519e0

Browse files
anoadragon453richvdh
authored andcommitted
Disable /register/available if registration is disabled (#6082)
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.
1 parent 1c9fead commit 1b519e0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

changelog.d/6082.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Return 403 on `/register/available` if registration has been disabled.

synapse/rest/client/v2_alpha/register.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ def __init__(self, hs):
328328

329329
@defer.inlineCallbacks
330330
def on_GET(self, request):
331+
if not self.hs.config.enable_registration:
332+
raise SynapseError(
333+
403, "Registration has been disabled", errcode=Codes.FORBIDDEN
334+
)
335+
331336
ip = self.hs.get_ip_from_request(request)
332337
with self.ratelimiter.ratelimit(ip) as wait_deferred:
333338
yield wait_deferred

0 commit comments

Comments
 (0)