Compare commits

...

4 Commits

Author SHA1 Message Date
Andrew Morgan
1a94f271e1 Rename *.fix -> *.bugfix 2024-09-10 17:34:58 +01:00
Quentin Gliech
bf84bbf0b9 Newsfile 2024-09-04 11:42:07 +02:00
Quentin Gliech
4c221322d8 Add a test to make sure registration is forbidden when MSC3861 is enabled 2024-09-04 11:38:09 +02:00
Quentin Gliech
8fc6727fe0 Make sure we say registration is disabled when MSC3861 is enabled 2024-09-04 11:37:49 +02:00
3 changed files with 24 additions and 5 deletions

1
changelog.d/17661.bugfix Normal file
View File

@@ -0,0 +1 @@
Make sure we advertise registration as disabled when MSC3861 is enabled.

View File

@@ -905,6 +905,14 @@ class RegisterAppServiceOnlyRestServlet(RestServlet):
await self.ratelimiter.ratelimit(None, client_addr, update=False)
# Allow only ASes to use this API.
if body.get("type") != APP_SERVICE_REGISTRATION_TYPE:
raise SynapseError(
403,
"Registration has been disabled. Only m.login.application_service registrations are allowed.",
errcode=Codes.FORBIDDEN,
)
kind = parse_string(request, "kind", default="user")
if kind == "guest":
@@ -920,10 +928,6 @@ class RegisterAppServiceOnlyRestServlet(RestServlet):
if not isinstance(desired_username, str) or len(desired_username) > 512:
raise SynapseError(400, "Invalid username")
# Allow only ASes to use this API.
if body.get("type") != APP_SERVICE_REGISTRATION_TYPE:
raise SynapseError(403, "Non-application service registration type")
if not self.auth.has_access_token(request):
raise SynapseError(
400,

View File

@@ -569,6 +569,16 @@ class MSC3861OAuthDelegation(HomeserverTestCase):
channel.json_body["errcode"], Codes.UNRECOGNIZED, channel.json_body
)
def expect_forbidden(
self, method: str, path: str, content: Union[bytes, str, JsonDict] = ""
) -> None:
channel = self.make_request(method, path, content)
self.assertEqual(channel.code, 403, channel.json_body)
self.assertEqual(
channel.json_body["errcode"], Codes.FORBIDDEN, channel.json_body
)
def test_uia_endpoints(self) -> None:
"""Test that endpoints that were removed in MSC2964 are no longer available."""
@@ -627,7 +637,11 @@ class MSC3861OAuthDelegation(HomeserverTestCase):
"GET", "/_matrix/client/v1/register/m.login.registration_token/validity"
)
# This is still available for AS registrations
# self.expect_unrecognized("POST", "/_matrix/client/v3/register")
self.expect_forbidden(
"POST",
"/_matrix/client/v3/register",
{"username": "alice", "password": "hunter2"},
)
self.expect_unrecognized("GET", "/_matrix/client/v3/register/available")
self.expect_unrecognized(
"POST", "/_matrix/client/v3/register/email/requestToken"