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

Commit 73be37e

Browse files
clokepFizzadar
authored andcommitted
Stop accepting 'user' parameter for application service registration. (matrix-org#15928)
This is unspecced, but has existed for a very long time.
1 parent 7265381 commit 73be37e

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
@@ -463,9 +463,9 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
463463
# the auth layer will store these in sessions.
464464
desired_username = None
465465
if "username" in body:
466-
if not isinstance(body["username"], str) or len(body["username"]) > 512:
467-
raise SynapseError(400, "Invalid username")
468466
desired_username = body["username"]
467+
if not isinstance(desired_username, str) or len(desired_username) > 512:
468+
raise SynapseError(400, "Invalid username")
469469

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

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

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

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

496492
result = await self._do_appservice_registration(

0 commit comments

Comments
 (0)