mirror of
https://github.com/YunoHost-Apps/nodered_ynh.git
synced 2024-09-03 19:46:25 +02:00
Add HTTP nodes permission
This commit is contained in:
parent
f87a720de8
commit
81793fcec9
6 changed files with 64 additions and 16 deletions
|
@ -21,7 +21,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
|||
|
||||
Flow-based programming for the Internet of Things
|
||||
|
||||
**Shipped version:** 1.3.5
|
||||
**Shipped version:** 1.3.5~ynh1
|
||||
|
||||
|
||||
|
||||
|
@ -38,6 +38,7 @@ Flow-based programming for the Internet of Things
|
|||
|
||||
* YunoHost's permissions system enables to select which users can have access to Node-RED. Upon installation, the selected administrator is the sole user to have access.
|
||||
* A `ui` permission is available in case you install the `node-red-dashboard` nodes. It makes the dashboard accessible to any authorized user or visitor, at `/ui` under Node-RED's address.
|
||||
* A `nodes` permission is available in case you need to use the HTTP nodes. By default, visitors have access to these endpoints at `/red-nodes/...` under Node-RED's address.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ Programmation par flux de données pour l'Internet des objets
|
|||
|
||||
* Le système de permissions de YunoHost permet de paramétrer les accès à Node-RED. Par défaut, seul l'administrateur sélectionné lors de l'installation y a accès.
|
||||
* Une permission `ui` est diponible au cas où vous installeriez les nodes de `node-red-dashboard`. Elle donne accès au tableau de bord à tout utilisateur ou visiteur autorisé, au chemin `/ui` après l'adresse spécifiée pour Node-RED.
|
||||
* Une permission `nodes` est disponible au cas où vous utiliseriez les nodes HTTP. Par défaut, les visiteurs auront accès à ces nodes, au chemin `/red-nodes/...` après l'adresse spécifiée pour Node-RED.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
* YunoHost's permissions system enables to select which users can have access to Node-RED. Upon installation, the selected administrator is the sole user to have access.
|
||||
* A `ui` permission is available in case you install the `node-red-dashboard` nodes. It makes the dashboard accessible to any authorized user or visitor, at `/ui` under Node-RED's address.
|
||||
* A `nodes` permission is available in case you need to use the HTTP nodes. By default, visitors have access to these endpoints at `/red-nodes/...` under Node-RED's address.
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
* Le système de permissions de YunoHost permet de paramétrer les accès à Node-RED. Par défaut, seul l'administrateur sélectionné lors de l'installation y a accès.
|
||||
* Une permission `ui` est diponible au cas où vous installeriez les nodes de `node-red-dashboard`. Elle donne accès au tableau de bord à tout utilisateur ou visiteur autorisé, au chemin `/ui` après l'adresse spécifiée pour Node-RED.
|
||||
* Une permission `nodes` est disponible au cas où vous utiliseriez les nodes HTTP. Par défaut, les visiteurs auront accès à ces nodes, au chemin `/red-nodes/...` après l'adresse spécifiée pour Node-RED.
|
||||
|
||||
|
|
|
@ -25,6 +25,13 @@ path_url=$YNH_APP_ARG_PATH
|
|||
admin=$YNH_APP_ARG_ADMIN
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
if [ $path_url = "/" ]
|
||||
then
|
||||
nodes_url="/red-nodes"
|
||||
else
|
||||
nodes_url="$path_url/red-nodes"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
|
@ -103,7 +110,14 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
mkdir -p $final_path/data
|
||||
cp $final_path/settings.js $final_path/data/settings.js
|
||||
ynh_replace_string --match_string="//httpRoot: '/red'," --replace_string="httpRoot: '$path_url'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Set editor path
|
||||
ynh_replace_string --match_string="//httpAdminRoot: '/admin'," --replace_string="httpAdminRoot: '$path_url'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Set nodes endpoints path
|
||||
ynh_replace_string --match_string="//httpNodeRoot: '/red-nodes'," --replace_string="httpNodeRoot: '$nodes_url'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Set dashboard path
|
||||
ynh_replace_string --match_string="//ui: { path: "ui" }," --replace_string="ui: { path: "/ui/" }," --target_file="$final_path/data/settings.js"
|
||||
|
||||
#=================================================
|
||||
|
@ -156,7 +170,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
ynh_permission_update --permission="main" --remove="all_users" --add="$admin"
|
||||
ynh_permission_create --permission="ui" --url="/ui" --allowed="$admin"
|
||||
ynh_permission_create --permission="nodes" --url="$nodes_path" --allowed="visitors" --label="nodes endpoints"
|
||||
ynh_permission_create --permission="ui" --url="/ui" --allowed="$admin" --label="dashboard"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
|
|
@ -21,12 +21,33 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
if [ $path_url = "/" ]
|
||||
then
|
||||
nodes_url="/red-nodes/"
|
||||
else
|
||||
nodes_url="$path_url/red-nodes/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up Node-RED before upgrading (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -45,19 +66,15 @@ if ynh_legacy_permissions_exists; then
|
|||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up Node-RED before upgrading (may take a while)..." --weight=1
|
||||
if ! ynh_permission_exists --permission="nodes"; then
|
||||
# Create the required permissions
|
||||
ynh_permission_create --permission="nodes" --url="$nodes_path" --allowed="visitors" --label="nodes endpoints"
|
||||
fi
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
if ! ynh_permission_exists --permission="ui"; then
|
||||
# Create the required permissions
|
||||
ynh_permission_create --permission="ui" --url="/ui" --label="dashboard"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CLOSING PORT
|
||||
|
@ -132,7 +149,17 @@ ynh_add_nginx_config
|
|||
if [ ! -f $final_path/data/settings.js ]; then
|
||||
cp $final_path/settings.js $final_path/data/settings.js
|
||||
fi
|
||||
ynh_replace_string --match_string="//httpRoot: '/red'," --replace_string="httpRoot: '$path_url'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Disable httpRoot from older installs
|
||||
ynh_replace_string --match_string="httpRoot: '$path_url'," --replace_string="//httpRoot: '/'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Set editor path
|
||||
ynh_replace_string --match_string="//httpAdminRoot: '/admin'," --replace_string="httpAdminRoot: '$path_url'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Set nodes endpoints path
|
||||
ynh_replace_string --match_string="//httpNodeRoot: '/red-nodes'," --replace_string="httpNodeRoot: '$nodes_url'," --target_file="$final_path/data/settings.js"
|
||||
|
||||
# Set dashboard path
|
||||
ynh_replace_string --match_string="//ui: { path: "ui" }," --replace_string="ui: { path: "/ui/" }," --target_file="$final_path/data/settings.js"
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue