This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Stop accepting 'user' parameter for application service registration. #15928
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove support for calling the `/register` endpoint with an unspecced `user` property for application services. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -462,9 +462,9 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: | |
# the auth layer will store these in sessions. | ||
desired_username = None | ||
if "username" in body: | ||
if not isinstance(body["username"], str) or len(body["username"]) > 512: | ||
raise SynapseError(400, "Invalid username") | ||
desired_username = body["username"] | ||
if not isinstance(desired_username, str) or len(desired_username) > 512: | ||
raise SynapseError(400, "Invalid username") | ||
|
||
# fork off as soon as possible for ASes which have completely | ||
# different registration flows to normal users | ||
|
@@ -477,19 +477,15 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: | |
"Appservice token must be provided when using a type of m.login.application_service", | ||
) | ||
|
||
# Set the desired user according to the AS API (which uses the | ||
# 'user' key not 'username'). Since this is a new addition, we'll | ||
# fallback to 'username' if they gave one. | ||
desired_username = body.get("user", desired_username) | ||
|
||
# XXX we should check that desired_username is valid. Currently | ||
# we give appservices carte blanche for any insanity in mxids, | ||
# because the IRC bridges rely on being able to register stupid | ||
# IDs. | ||
|
||
access_token = self.auth.get_access_token_from_request(request) | ||
|
||
if not isinstance(desired_username, str): | ||
# Desired username is either a string or None. | ||
if desired_username is None: | ||
raise SynapseError(400, "Desired Username is missing or not a string") | ||
Comment on lines
+487
to
489
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally assumed we could remove this validation, but we can't -- for application services it is invalid to not give the |
||
|
||
result = await self._do_appservice_registration( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a no-op change; I just found it easier to fetch the property once and re-use it instead of doing it after validation.