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
Add a config flag to inhibit M_USER_IN_USE
during registration
#11743
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
abdcd9f
Add a config flag to ignore client-supplied usernames at registration
babolivier 5236947
Fix changelog number
babolivier d7f4db1
Sample config
babolivier 4c77107
Correctly ignore the username when pulling it from a UIA session
babolivier f4a69b8
Make test failure less noisy
babolivier ffd629d
Incorporate comments from discussion
babolivier 540e0ca
Fixup changelog
babolivier 43af50c
Lint
babolivier 3375b21
Config
babolivier 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 @@ | ||
Add a config flag to inhibit M_USER_IN_USE during registration. |
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
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 |
---|---|---|
|
@@ -339,12 +339,19 @@ def __init__(self, hs: "HomeServer"): | |
), | ||
) | ||
|
||
self.inhibit_user_in_use_error = ( | ||
hs.config.registration.inhibit_user_in_use_error | ||
) | ||
|
||
async def on_GET(self, request: Request) -> Tuple[int, JsonDict]: | ||
if not self.hs.config.registration.enable_registration: | ||
raise SynapseError( | ||
403, "Registration has been disabled", errcode=Codes.FORBIDDEN | ||
) | ||
|
||
if self.inhibit_user_in_use_error: | ||
return 200, {"available": True} | ||
|
||
ip = request.getClientIP() | ||
with self.ratelimiter.ratelimit(ip) as wait_deferred: | ||
await wait_deferred | ||
|
@@ -422,6 +429,9 @@ def __init__(self, hs: "HomeServer"): | |
self._refresh_tokens_enabled = ( | ||
hs.config.registration.refreshable_access_token_lifetime is not None | ||
) | ||
self._inhibit_user_in_use_error = ( | ||
hs.config.registration.inhibit_user_in_use_error | ||
) | ||
|
||
self._registration_flows = _calculate_registration_flows( | ||
hs.config, self.auth_handler | ||
|
@@ -564,6 +574,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: | |
desired_username, | ||
guest_access_token=guest_access_token, | ||
assigned_user_id=registered_user_id, | ||
inhibit_user_in_use_error=self._inhibit_user_in_use_error, | ||
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'm not adding another check later on (e.g. after we've checked that the UIA flow is complete) because the registration handler's |
||
) | ||
|
||
# Check if the user-interactive authentication flows are complete, if | ||
|
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
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.
Part of me feels uncomfortable lying here. I wondered about returning 400 or 403 with an appropriate error code. But I can imagine a) that clients would break, and b) that would require a spec change.