mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-04 08:13:38 +00:00
matrixsynapse: Disable verification to fix public registrations
Closes: #2321. - Without verification configuration being set, if public registrations are enabled, matrix-synapse server does not start. Fix this by disabling registration verification. Tests: - Without the patch, install matrix and enable public registrations. Matrix daemon will no longer be running. Apply patches and restart. Matrix app will be updated. 'enable_registration_without_verification: true' will appear in /etc/matrix-synapse/conf.d/freedombox-registration.yaml. Server will be running. - Enabling/disabling the public registration option works. The option will be added and removed. enable_public_registration is set to true/false. - Functional tests for matrix-synapse work. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
89a404fb7d
commit
7729eec96f
@ -44,7 +44,7 @@ class MatrixSynapseApp(app_module.App):
|
||||
|
||||
app_id = 'matrixsynapse'
|
||||
|
||||
_version = 7
|
||||
_version = 8
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
@ -114,6 +114,9 @@ class MatrixSynapseApp(app_module.App):
|
||||
else:
|
||||
privileged.post_install()
|
||||
|
||||
if old_version and old_version <= 7:
|
||||
privileged.fix_public_registrations()
|
||||
|
||||
if not old_version:
|
||||
self.enable()
|
||||
|
||||
|
||||
@ -79,15 +79,25 @@ def get_config():
|
||||
with open(ORIG_CONF_PATH, encoding='utf-8') as orig_conf_file:
|
||||
config = yaml.safe_load(orig_conf_file)
|
||||
|
||||
if config.get('enable_registration_without_verification'):
|
||||
registration_verification = 'disabled'
|
||||
else:
|
||||
registration_verification = None
|
||||
|
||||
return {
|
||||
'public_registration': bool(config.get('enable_registration', False)),
|
||||
'registration_verification': registration_verification,
|
||||
}
|
||||
|
||||
|
||||
@privileged
|
||||
def set_config(public_registration: bool):
|
||||
def set_config(public_registration: bool,
|
||||
registration_verification: Optional[str] = None):
|
||||
"""Enable/disable public user registration."""
|
||||
config = {'enable_registration': public_registration}
|
||||
if public_registration and registration_verification in ('disabled', None):
|
||||
config['enable_registration_without_verification'] = True
|
||||
|
||||
with open(REGISTRATION_CONF_PATH, 'w', encoding='utf-8') as reg_conf_file:
|
||||
yaml.dump(config, reg_conf_file)
|
||||
|
||||
@ -135,3 +145,13 @@ def configure_turn(managed: bool, conf: str):
|
||||
_set_turn_config(OVERRIDDEN_TURN_CONF_PATH, conf)
|
||||
|
||||
action_utils.service_try_restart('matrix-synapse')
|
||||
|
||||
|
||||
@privileged
|
||||
def fix_public_registrations():
|
||||
"""If public registrations are enabled, set validation mechanism."""
|
||||
config = get_config()
|
||||
if (config['public_registration']
|
||||
and config['registration_verification'] is None):
|
||||
set_config(public_registration=True,
|
||||
registration_verification='disabled')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user