From 2c930a8989bf58481c4b126430256f3c6535472f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Mon, 11 Nov 2019 21:43:19 +0100 Subject: [PATCH] Add public room access option --- config_panel.json | 6 ++++++ scripts/config | 4 ++++ scripts/install | 5 ++++- scripts/upgrade | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/config_panel.json b/config_panel.json index 0b02983..b6fda34 100644 --- a/config_panel.json +++ b/config_panel.json @@ -19,6 +19,12 @@ "type": "bool", "help": "Is it a public server", "default": false + },{ + "name": "Server public", + "id": "allow_public_rooms", + "type": "bool", + "help": "If set to 'false', requires authentication to access the server's public rooms directory through the client API and forbids any other homeserver to fetch the server's public rooms directory via federation.", + "default": false }] }] },{ diff --git a/scripts/config b/scripts/config index 2843819..e648149 100644 --- a/scripts/config +++ b/scripts/config @@ -30,6 +30,7 @@ show_config() { # here you are supposed to read some config file/database/other then print the values # echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" echo "YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_SERVER_STATISTICS=$(ynh_app_setting_get --app $app --key report_stats)" + echo "YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_ALLOW_PUBLIC_ROOMS=$(ynh_app_setting_get --app $app --key allow_public_rooms)" backup_before_upgrade=$(ynh_app_setting_get --app $app --key disable_backup_before_upgrade) if [[ ${backup_before_upgrade:-0} -eq 1 ]] @@ -53,6 +54,7 @@ show_config() { apply_config() { ynh_app_setting_set --app $app --key report_stats --value $YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_SERVER_STATISTICS + ynh_app_setting_set --app $app --key allow_public_rooms --value $YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_ALLOW_PUBLIC_ROOMS if ${YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE,,} then @@ -79,6 +81,7 @@ apply_config() { registration_shared_secret=$(ynh_app_setting_get --app $app --key registration_shared_secret) form_secret=$(ynh_app_setting_get --app $app --key form_secret) report_stats=$(ynh_app_setting_get --app $app --key report_stats) + allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) synapse_user="matrix-$app" synapse_db_name="matrix_$app" synapse_db_user="matrix_$app" @@ -107,6 +110,7 @@ apply_config() { ynh_replace_string --match_string __REGISTRATION_SECRET__ --replace_string "$registration_shared_secret" --target_file "$homeserver_config_path" ynh_replace_string --match_string __FORM_SECRET__ --replace_string "$form_secret" --target_file "$homeserver_config_path" ynh_replace_string --match_string __REPORT_STATS__ --replace_string "$report_stats" --target_file "$homeserver_config_path" + ynh_replace_string --match_string=__ALLOW_PUBLIC_ROOMS__ --replace_string="$allow_public_rooms" --target_file="$homeserver_config_path" if [ "$is_public" = "0" ] then diff --git a/scripts/install b/scripts/install index 4a8280a..5043327 100644 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,8 @@ synapse_user="matrix-$app" synapse_db_name="matrix_$app" synapse_db_user="matrix_$app" upstream_version=$(ynh_app_upstream_version) -report_stats="False" +report_stats="false" +allow_public_rooms="false" default_domain_value="Same than the domain" #================================================= @@ -82,6 +83,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=synapse_version --value=$upstream_version ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats +ynh_app_setting_set --app=$app --key=allow_public_rooms --value=$allow_public_rooms #================================================= # STANDARD MODIFICATIONS @@ -274,6 +276,7 @@ ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file= ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$synapse_tls_port --target_file="$homeserver_config_path" ynh_replace_string --match_string=__TURNSERVER_TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$homeserver_config_path" ynh_replace_string --match_string=__REPORT_STATS__ --replace_string="$report_stats" --target_file="$homeserver_config_path" +ynh_replace_string --match_string=__ALLOW_PUBLIC_ROOMS__ --replace_string="$allow_public_rooms" --target_file="$homeserver_config_path" ynh_print_OFF ynh_replace_string --match_string=__SYNAPSE_DB_PWD__ --replace_string=$synapse_db_pwd --target_file="$homeserver_config_path" ynh_replace_special_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$homeserver_config_path" diff --git a/scripts/upgrade b/scripts/upgrade index 892f552..f832d9d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,7 @@ turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) report_stats=$(ynh_app_setting_get --app=$app --key=report_stats) +allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) ynh_print_OFF synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) @@ -169,6 +170,18 @@ then fi ynh_print_ON +#================================================= +# MIGRATION 5 : DEFINE UNDEFINED SETTINGS +#================================================= + +if [ -n $report_stats ]; then + report_stats="false" +fi + +if [ -n $allow_public_rooms ]; then + allow_public_rooms="false" +fi + #================================================= # UPDATE SYNAPSE CONFIG #================================================= @@ -193,6 +206,7 @@ ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file= ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$synapse_tls_port --target_file="$homeserver_config_path" ynh_replace_string --match_string=__TURNSERVER_TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$homeserver_config_path" ynh_replace_string --match_string=__REPORT_STATS__ --replace_string="$report_stats" --target_file="$homeserver_config_path" +ynh_replace_string --match_string=__ALLOW_PUBLIC_ROOMS__ --replace_string="$allow_public_rooms" --target_file="$homeserver_config_path" ynh_print_OFF ynh_replace_string --match_string=__SYNAPSE_DB_PWD__ --replace_string=$synapse_db_pwd --target_file="$homeserver_config_path" ynh_replace_special_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$homeserver_config_path"