1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00

restructure allowed_local_3pids

This commit is contained in:
gredin67 2023-01-19 10:08:18 +01:00
parent 2faeeb5b75
commit 75349b38b7
4 changed files with 53 additions and 31 deletions

View file

@ -1283,9 +1283,7 @@ disable_msisdn_registration: __DISABLE_MSISDN_REGISTRATION__
# Mandate that users are only allowed to associate certain formats of # Mandate that users are only allowed to associate certain formats of
# 3PIDs with accounts on this server. # 3PIDs with accounts on this server.
# #
allowed_local_3pids: #allowed_local_3pids:
- medium: __REGISTRATIONS_REQUIRE_3PID__
pattern: __ALLOWED_LOCAL_3PIDS__
# - medium: email # - medium: email
# pattern: '^[^@]+@vector\.im$' # pattern: '^[^@]+@vector\.im$'
# - medium: msisdn # - medium: msisdn
@ -1293,7 +1291,7 @@ allowed_local_3pids:
# Enable 3PIDs lookup requests to identity servers from this server. # Enable 3PIDs lookup requests to identity servers from this server.
# #
#enable_3pid_lookup: true enable_3pid_lookup: __ENABLE_3PID_LOOKUP__
# Require users to submit a token during registration. # Require users to submit a token during registration.
# Tokens can be managed using the admin API: # Tokens can be managed using the admin API:

View file

@ -25,27 +25,27 @@ services = ["matrix-__APP__"]
visible = "! enable_registration" visible = "! enable_registration"
[main.welcome.registrations_require_3pid] [main.welcome.registrations_require_3pid]
ask = "Register only with all following types of 3PID." ask = "Registration requires all following 3PID personal identifier."
type = "select" type = "select"
choices = ["false","email", "msidn", "email&msisdn"] choices = ["false","email", "msisdn", "email&msisdn"]
help = "Defaults to: 'email'. Phone number: 'msisdn'" help = "Defaults to: 'email'. Phone number: 'msisdn'"
visible = "enable_registration" visible = "enable_registration"
[main.welcome.allowed_local_3pids] [main.welcome.allowed_local_3pids_email]
ask = "Register only with given formats of 3PIDs." ask = "Register only with given email formats."
type = "string" type = "tags"
help = ''' help = "'^[^@]+@matrix\.org$'"
allowed_local_3pids: visible = 'enable_registration && (registrations_require_3pid == "email" || registrations_require_3pid == "email&msisdn")'
- medium: email
pattern: '^[^@]+@matrix\.org$' [main.welcome.allowed_local_3pids_msisdn]
- medium: msisdn ask = "Register only with given phone number formats."
pattern: '\+33' type = "tags"
''' help = "'\+33'"
visible = "registrations_require_3pid != 'false'" visible = 'enable_registration && (registrations_require_3pid == "email&msisdn" || registrations_require_3pid == "msisdn")'
[main.welcome.auto_join_rooms] [main.welcome.auto_join_rooms]
ask = "Auto Join new Users in following Rooms:" ask = "Auto Join new Users in following Rooms:"
type = "string" type = "tags"
help = "Users who register on this homeserver will automatically be joined to these rooms. If the room already exists, the join rule must be set to 'public'. See also next setting." help = "Users who register on this homeserver will automatically be joined to these rooms. If the room already exists, the join rule must be set to 'public'. See also next setting."
bind = ":/etc/matrix-__APP__/homeserver.yaml" bind = ":/etc/matrix-__APP__/homeserver.yaml"
@ -105,9 +105,9 @@ services = ["matrix-__APP__"]
name = "User Experience" name = "User Experience"
[main.experience.web_client_location] [main.experience.web_client_location]
ask = "URL to the web client which / will redirect to." ask = "Element instance your HomeServer should redirect to."
type = "url" type = "url"
help = "Basically Element instance the server should redirect to." help = "URL to the web client which / will redirect to."
bind = ":/etc/matrix-__APP__/homeserver.yaml" bind = ":/etc/matrix-__APP__/homeserver.yaml"
[main.experience.enable_group_creation] [main.experience.enable_group_creation]
@ -115,7 +115,7 @@ services = ["matrix-__APP__"]
type = "boolean" type = "boolean"
yes = true yes = true
no = false no = false
help = "Defaults to 'false'." help = "Disabled by default: only server admins can create Spaces"
bind = ":/etc/matrix-__APP__/homeserver.yaml" bind = ":/etc/matrix-__APP__/homeserver.yaml"
[main.experience.enable_notifs] [main.experience.enable_notifs]
@ -131,6 +131,7 @@ services = ["matrix-__APP__"]
type = "url" type = "url"
help = "Used to be called 'riot_base_url', still supported" help = "Used to be called 'riot_base_url', still supported"
bind = ":/etc/matrix-__APP__/homeserver.yaml" bind = ":/etc/matrix-__APP__/homeserver.yaml"
visible = "enable_notifs"
[resources] [resources]
name = "Resource Usage" name = "Resource Usage"
@ -150,11 +151,11 @@ name = "Advanced Settings"
services = ["matrix-__APP__"] services = ["matrix-__APP__"]
[advanced.help] [advanced.help]
name = "ONLY CHANGE THIS IF YOU'RE AN EXPERT IN SERVER ADMINISTRATION" name = "SETTINGS FOR EXPERTS IN SERVER ADMINISTRATION"
[advanced.help.text] [advanced.help.text]
ask = ''' ask = '''
**There are security and privacy risks if you change these settings without knowing what you do!** !!There are security and privacy risks if you change these settings without knowing what you do!!
''' '''
type = "markdown" type = "markdown"
@ -166,7 +167,7 @@ services = ["matrix-__APP__"]
type = "boolean" type = "boolean"
yes = true yes = true
no = false no = false
help = "!!If disabled, do a manual backup before upgrade!! Enable if your Synapse instance is huge and you prefer to disable the backup that is normally automatically done before each upgrade." help = "!! If disabled, do a manual backup before upgrade !! Disable if your Synapse instance is huge and you prefer to disable the backup that is normally automatically done before each upgrade."
[advanced.others.server_statistics] [advanced.others.server_statistics]
ask = "Server statistics" ask = "Server statistics"
@ -204,10 +205,18 @@ services = ["matrix-__APP__"]
[advanced.privacy] [advanced.privacy]
name = "Data Privacy" name = "Data Privacy"
[advanced.privacy.enable_3pid_lookup]
ask = "Allow discovering friends with phone number or email?"
type = "boolean"
yes = true
no = false
help = "Enable 3PIDs lookup requests to identity servers from this server. See Settings->General->Discovery in Element."
bind = ":/etc/matrix-__APP__/homeserver.yaml"
[advanced.privacy.default_identity_server] [advanced.privacy.default_identity_server]
ask = "Identity server suggested to clients?" ask = "Identity server suggested to clients?"
type = "url" type = "url"
help = "By default, no suggestion is made, so it is left up to the client." help = "Identity server allows to discover, be discovered and invite people you know with phone number or email. If not set, users will probably chose centralized vector.im. See Settings->General->Discovery in Element."
bind = ":/etc/matrix-__APP__/homeserver.yaml" bind = ":/etc/matrix-__APP__/homeserver.yaml"
[advanced.privacy.allow_public_rooms_without_auth] [advanced.privacy.allow_public_rooms_without_auth]

View file

@ -91,17 +91,20 @@ then
turn_allow_guests="false" turn_allow_guests="false"
sso_enabled="true" sso_enabled="true"
password_enabled="false" password_enabled="false"
enable_3pid_lookup="false"
else else
enable_registration="true" enable_registration="true"
turn_allow_guests="true" turn_allow_guests="true"
sso_enabled="false" sso_enabled="false"
password_enabled="true" password_enabled="true"
enable_3pid_lookup="true"
fi fi
ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration
ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests
ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
ynh_app_setting_set --app=$app --key=enable_3pid_lookup --value=$enable_3pid_lookup
#================================================= #=================================================
## SET STANDARD SETTINGS FROM DEFAULT CONFIG ## SET STANDARD SETTINGS FROM DEFAULT CONFIG
@ -130,7 +133,8 @@ max_upload_size="10M"
disable_msisdn_registration="true" disable_msisdn_registration="true"
registrations_require_3pid="email" registrations_require_3pid="email"
# here we need sed magic to transform $server_name # here we need sed magic to transform $server_name
allowed_local_3pids="'^[^@]+@""matrix""\.org$'" allowed_local_3pids_email="'^[^@]+@""matrix""\.org$'"
allowed_local_3pids_msisdn="'\+33'"
allow_guest_access="false" allow_guest_access="false"
default_identity_server="https://matrix.org" default_identity_server="https://matrix.org"
auto_join_rooms="#auto_join_room:""$server_name" auto_join_rooms="#auto_join_room:""$server_name"
@ -151,7 +155,8 @@ ynh_app_setting_set --app=$app --key=allow_public_rooms_over_federation --value=
ynh_app_setting_set --app=$app --key=max_upload_size --value=$max_upload_size ynh_app_setting_set --app=$app --key=max_upload_size --value=$max_upload_size
ynh_app_setting_set --app=$app --key=disable_msisdn_registration --value=$disable_msisdn_registration ynh_app_setting_set --app=$app --key=disable_msisdn_registration --value=$disable_msisdn_registration
ynh_app_setting_set --app=$app --key=registrations_require_3pid --value=$registrations_require_3pid ynh_app_setting_set --app=$app --key=registrations_require_3pid --value=$registrations_require_3pid
ynh_app_setting_set --app=$app --key=allowed_local_3pids --value=$allowed_local_3pids ynh_app_setting_set --app=$app --key=allowed_local_3pids_email --value=$allowed_local_3pids_email
ynh_app_setting_set --app=$app --key=allowed_local_3pids_msisdn --value=$allowed_local_3pids_msisdn
ynh_app_setting_set --app=$app --key=allow_guest_access --value=$allow_guest_access ynh_app_setting_set --app=$app --key=allow_guest_access --value=$allow_guest_access
ynh_app_setting_set --app=$app --key=default_identity_server --value=$default_identity_server ynh_app_setting_set --app=$app --key=default_identity_server --value=$default_identity_server
ynh_app_setting_set --app=$app --key=auto_join_rooms --value=$auto_join_rooms ynh_app_setting_set --app=$app --key=auto_join_rooms --value=$auto_join_rooms

View file

@ -70,7 +70,8 @@ allow_public_rooms_over_federation=$(ynh_app_setting_get --app=$app --key=allow_
max_upload_size=$(ynh_app_setting_get --app=$app --key=max_upload_size) max_upload_size=$(ynh_app_setting_get --app=$app --key=max_upload_size)
disable_msisdn_registration=$(ynh_app_setting_get --app=$app --key=disable_msisdn_registration) disable_msisdn_registration=$(ynh_app_setting_get --app=$app --key=disable_msisdn_registration)
registrations_require_3pid=$(ynh_app_setting_get --app=$app --key=registrations_require_3pid) registrations_require_3pid=$(ynh_app_setting_get --app=$app --key=registrations_require_3pid)
allowed_local_3pids=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids) allowed_local_3pids_email=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids_email)
allowed_local_3pids_msisdn=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids_msisdn)
allow_guest_access=$(ynh_app_setting_get --app=$app --key=allow_guest_access) allow_guest_access=$(ynh_app_setting_get --app=$app --key=allow_guest_access)
default_identity_server=$(ynh_app_setting_get --app=$app --key=default_identity_server) default_identity_server=$(ynh_app_setting_get --app=$app --key=default_identity_server)
auto_join_rooms=$(ynh_app_setting_get --app=$app --key=auto_join_rooms) auto_join_rooms=$(ynh_app_setting_get --app=$app --key=auto_join_rooms)
@ -84,6 +85,7 @@ enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration)
turn_allow_guests=$(ynh_app_setting_get --app=$app --key=turn_allow_guests) turn_allow_guests=$(ynh_app_setting_get --app=$app --key=turn_allow_guests)
sso_enabled=$(ynh_app_setting_get --app=$app --key=sso_enabled) sso_enabled=$(ynh_app_setting_get --app=$app --key=sso_enabled)
password_enabled=$(ynh_app_setting_get --app=$app --key=password_enabled) password_enabled=$(ynh_app_setting_get --app=$app --key=password_enabled)
enable_3pid_lookup=$(ynh_app_setting_get --app=$app --key=enable_3pid_lookup)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
@ -274,10 +276,15 @@ then
registrations_require_3pid="email" registrations_require_3pid="email"
ynh_app_setting_set --app=$app --key=registrations_require_3pid --value=$registrations_require_3pid ynh_app_setting_set --app=$app --key=registrations_require_3pid --value=$registrations_require_3pid
fi fi
if [ -z "$allowed_local_3pids" ] if [ -z "$allowed_local_3pids_email" ]
then then
allowed_local_3pids="'^[^@]+@""matrix""\.org$'" allowed_local_3pids_email="'^[^@]+@""matrix""\.org$'"
ynh_app_setting_set --app=$app --key=allowed_local_3pids --value=$allowed_local_3pids ynh_app_setting_set --app=$app --key=allowed_local_3pids_email --value=$allowed_local_3pids_email
fi
if [ -z "$allowed_local_3pids_msisdn" ]
then
allowed_local_3pids_msisdn="'\+33'"
ynh_app_setting_set --app=$app --key=allowed_local_3pids_msisdn --value=$allowed_local_3pids_msisdn
fi fi
if [ -z "$allow_guest_access" ] if [ -z "$allow_guest_access" ]
then then
@ -328,16 +335,19 @@ then
turn_allow_guests="false" turn_allow_guests="false"
sso_enabled="true" sso_enabled="true"
password_enabled="false" password_enabled="false"
enable_3pid_lookup="false"
else else
enable_registration="true" enable_registration="true"
turn_allow_guests="true" turn_allow_guests="true"
sso_enabled="false" sso_enabled="false"
password_enabled="true" password_enabled="true"
enable_3pid_lookup="true"
fi fi
ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration
ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests
ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
ynh_app_setting_set --app=$app --key=enable_3pid_lookup --value=$enable_3pid_lookup
fi fi
#================================================= #=================================================