diff --git a/conf/nginx.conf b/conf/nginx.conf index 3aad432..8642d49 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,7 +15,7 @@ location __PATH__ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme; proxy_set_header X-Script-Name __PATH__; -# proxy_set_header X-Remote-User $remote_user; +# proxy_set_header X-Remote-User $remote_user; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess new file mode 100644 index 0000000..b2e7581 --- /dev/null +++ b/hooks/post_app_addaccess @@ -0,0 +1,19 @@ +#!/bin/bash +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +app=$1 +users=$2 +permission=$3 +group=$4 + +#Si le groupe visitors a été affecté à calibreweb +if echo "$group" | grep visitors ; then + if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep " proxy_set_header X-Remote-User"; then + #app is made public + domain=$(ynh_app_setting_get --app=$app --key=domain) + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" --replace_string="# proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + fi +fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess new file mode 100644 index 0000000..3250b25 --- /dev/null +++ b/hooks/post_app_removeaccess @@ -0,0 +1,18 @@ +#!/bin/bash +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +app=$1 +users=$2 +permission=$3 +group=$4 + +if echo "$group" | grep visitors; then + if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep "# proxy_set_header X-Remote-User"; then + #app is made public + domain=$(ynh_app_setting_get --app=$app --key=domain) + ynh_replace_string --match_string="# proxy_set_header X-Remote-User" --replace_string=" proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + fi +fi \ No newline at end of file