1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flarum_ynh.git synced 2024-09-03 18:36:24 +02:00

[upg] YNH v3.7 permissions system

Closes #139
This commit is contained in:
tituspijean 2020-03-27 19:21:46 +00:00
parent 6c0f19d95b
commit 73716beb99
3 changed files with 35 additions and 28 deletions

View file

@ -9,13 +9,13 @@
}, },
"url": "http://flarum.org/", "url": "http://flarum.org/",
"license": "MIT", "license": "MIT",
"version": "0.1.0-beta.12~ynh1", "version": "0.1.0-beta.12~ynh2",
"maintainer": { "maintainer": {
"name": "tituspijean", "name": "tituspijean",
"email": "tituspijean@outlook.com" "email": "tituspijean@outlook.com"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.5.0" "yunohost": ">= 3.7"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [

View file

@ -71,7 +71,6 @@ ynh_webpath_register $app $domain $path_url
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app language $language ynh_app_setting_set $app language $language
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set $app php_version $php_version ynh_app_setting_set $app php_version $php_version
@ -179,18 +178,16 @@ ynh_add_fpm_config $php_version
ynh_use_logrotate ynh_use_logrotate
#================================================= #=================================================
# SETUP SSOWAT # SETUP PERMISSIONS
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --time --weight=1
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway. # Everyone can access the app.
ynh_app_setting_set $app unprotected_uris "/" # The "main" permission is automatically created before the install script.
ynh_permission_update --permission "main" --add "visitors"
fi fi
#================================================= #=================================================

View file

@ -24,7 +24,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language) language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
@ -51,15 +50,6 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -72,6 +62,32 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# Cleaning legacy permissions
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris)
unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris)
protected_uris=$(ynh_app_setting_get --app=$app --key=protected_uris)
# Remove is_public if exists
if [ ! -z "$is_public" ]; then
ynh_app_setting_delete --app=$app --key=is_public
fi
# Remove skipped_uris if exists
if [ ! -z "$skipped_uris" ]; then
ynh_app_setting_delete --app=$app --key=skipped_uris
fi
# Remove unprotected_uris if exists
if [ ! -z "$unprotected_uris" ]; then
ynh_app_setting_delete --app=$app --key=unprotected_uris
fi
# Remove protected_uris if exists
if [ ! -z "$protected_uris" ]; then
ynh_app_setting_delete --app=$app --key=protected_uris
fi
# If some settings are missing, assume older package version # If some settings are missing, assume older package version
[ -z "$old_project_version" ] && old_project_version="0.1.0-beta.7" [ -z "$old_project_version" ] && old_project_version="0.1.0-beta.7"
[ -z "$old_ssowat_version" ] && old_ssowat_version="0.6" [ -z "$old_ssowat_version" ] && old_ssowat_version="0.6"
@ -285,16 +301,10 @@ chown -R $app:www-data $final_path/storage
chmod -R 0775 $final_path chmod -R 0775 $final_path
#================================================= #=================================================
# SETUP SSOWAT # SETUP PERMISSIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
# Make app public if necessary #ynh_script_progression --message="Upgrading permissions configuration..." --time --weight=1
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX