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 restrictions by default to open registration in Synapse #12091
Merged
Merged
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
be96970
refuse to start if registration is enabled without email or captcha v…
H-Shay 46f86b6
add config flag `enable_registration_without_verification` and associ…
H-Shay 8cddb87
test that enabling registration without verification throws error
H-Shay cb55db5
newsfragment
H-Shay 25aa51b
generate new sample config
H-Shay 97b1c95
lint
H-Shay 0e328cb
add newline on newsfile
H-Shay 3b21267
regenerate sample config
H-Shay 1d66611
Merge branch 'develop' into shay/restrict_registration
H-Shay dabf316
add token-based verification as a viable verification method
H-Shay 338c435
update sample config
H-Shay 2f8fcc0
Merge branch 'develop' into shay/restrict_registration
H-Shay a0582ed
fix misconfigured test
H-Shay 8346255
fix test causing errors
H-Shay 9b89835
lints
H-Shay b14b653
Merge branch 'develop' into shay/restrict_registration
H-Shay 717af3c
enable open registration by default in demo script
H-Shay e1a9098
Merge branch 'develop' into shay/restrict_registration
H-Shay 0cd6a60
add spaces in error message
H-Shay 366da79
requested changes
H-Shay 39ffa66
Merge branch 'develop' into shay/restrict_registration
H-Shay d99a1f1
Update docs/upgrade.md
H-Shay 11fa645
remove unreachable code
H-Shay 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 @@ | ||
Refuse to start if registration is enabled without email or captcha verification unless new config flag `enable_registration_without_verification` is set. | ||
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 |
---|---|---|
|
@@ -11,14 +11,16 @@ | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import synapse.app.homeserver | ||
from synapse.config import ConfigError | ||
from synapse.config.homeserver import HomeServerConfig | ||
|
||
from tests.unittest import TestCase | ||
from tests.config.utils import ConfigFileTestCase | ||
from tests.utils import default_config | ||
|
||
|
||
class RegistrationConfigTestCase(TestCase): | ||
class RegistrationConfigTestCase(ConfigFileTestCase): | ||
def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): | ||
""" | ||
session_lifetime should logically be larger than, or at least as large as, | ||
|
@@ -76,3 +78,22 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): | |
HomeServerConfig().parse_config_dict( | ||
{"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict} | ||
) | ||
|
||
def test_refuse_to_start_if_open_registration_and_no_verification(self): | ||
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. It's only config and straight-forward code so it's tempting not to bother, but this is only testing the negative. You may also be tempted to test that startup is able to proceed if both 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. Hmm I tested this condition locally and it works. Looking at the test though it feels like it's not necessary to add permanently to the tests. If you feel strongly about it I will, though. |
||
self.generate_config() | ||
self.add_lines_to_config( | ||
[ | ||
" ", | ||
"enable_registration: true", | ||
"registrations_require_3pid: false", | ||
"enable_registration_captcha: false", | ||
] | ||
) | ||
|
||
# Test that allowing open registration without verification raises an error | ||
with self.assertRaises(ConfigError): | ||
synapse.app.homeserver.setup(["-c", self.config_file]) | ||
|
||
# Test that setting `enable_registration_without_verification` to true overrides config error | ||
self.add_lines_to_config(["enable_registration_without_verification: true"]) | ||
synapse.app.homeserver.setup(["-c", self.config_file]) |
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.
We should add a line to https://matrix-org.github.io/synapse/latest/upgrade, as this change will require a subset of administrators to fiddle with their config before their homeserver can start up again.