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

Commit 20ae617

Browse files
authored
Stop accepting 'user' parameter for application service registration. (#15928)
This is unspecced, but has existed for a very long time.
1 parent 2cacd08 commit 20ae617

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

changelog.d/15928.removal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove support for calling the `/register` endpoint with an unspecced `user` property for application services.

docs/upgrade.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ process, for example:
8888
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
8989
```
9090
91+
# Upgrading to v1.89.0
92+
93+
## Removal of unspecced `user` property for `/register`
94+
95+
Application services can no longer call `/register` with a `user` property to create new users.
96+
The standard `username` property should be used instead. See the
97+
[Application Service specification](https://spec.matrix.org/v1.7/application-service-api/#server-admin-style-permissions)
98+
for more information.
99+
100+
91101
# Upgrading to v1.88.0
92102
93103
## Minimum supported Python version

synapse/rest/client/register.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
462462
# the auth layer will store these in sessions.
463463
desired_username = None
464464
if "username" in body:
465-
if not isinstance(body["username"], str) or len(body["username"]) > 512:
466-
raise SynapseError(400, "Invalid username")
467465
desired_username = body["username"]
466+
if not isinstance(desired_username, str) or len(desired_username) > 512:
467+
raise SynapseError(400, "Invalid username")
468468

469469
# fork off as soon as possible for ASes which have completely
470470
# different registration flows to normal users
@@ -477,19 +477,15 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
477477
"Appservice token must be provided when using a type of m.login.application_service",
478478
)
479479

480-
# Set the desired user according to the AS API (which uses the
481-
# 'user' key not 'username'). Since this is a new addition, we'll
482-
# fallback to 'username' if they gave one.
483-
desired_username = body.get("user", desired_username)
484-
485480
# XXX we should check that desired_username is valid. Currently
486481
# we give appservices carte blanche for any insanity in mxids,
487482
# because the IRC bridges rely on being able to register stupid
488483
# IDs.
489484

490485
access_token = self.auth.get_access_token_from_request(request)
491486

492-
if not isinstance(desired_username, str):
487+
# Desired username is either a string or None.
488+
if desired_username is None:
493489
raise SynapseError(400, "Desired Username is missing or not a string")
494490

495491
result = await self._do_appservice_registration(

0 commit comments

Comments
 (0)