From 65fff6b2c69b3028a4dc664ce7d9df95a8719dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Sun, 30 Dec 2018 15:58:45 +0100 Subject: [PATCH 1/2] Create app to check the permissions --- permissions_app_ynh/conf/empty | 1 + permissions_app_ynh/manifest.json | 46 ++++++++++++++++++++++++++ permissions_app_ynh/scripts/change_url | 24 ++++++++++++++ permissions_app_ynh/scripts/install | 27 +++++++++++++++ permissions_app_ynh/scripts/remove | 11 ++++++ 5 files changed, 109 insertions(+) create mode 100644 permissions_app_ynh/conf/empty create mode 100644 permissions_app_ynh/manifest.json create mode 100644 permissions_app_ynh/scripts/change_url create mode 100644 permissions_app_ynh/scripts/install create mode 100644 permissions_app_ynh/scripts/remove diff --git a/permissions_app_ynh/conf/empty b/permissions_app_ynh/conf/empty new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/permissions_app_ynh/conf/empty @@ -0,0 +1 @@ + diff --git a/permissions_app_ynh/manifest.json b/permissions_app_ynh/manifest.json new file mode 100644 index 0000000..7c3b36a --- /dev/null +++ b/permissions_app_ynh/manifest.json @@ -0,0 +1,46 @@ +{ + "name": "Permissions Test", + "id": "permissions_app", + "description": { + "en": "Dummy app to test permissions" + }, + "license": "GPL-3+", + "license": "Apache-2.0", + "maintainer": { + "name": "Josué Tille", + "email": "josue@tille.ch" + }, + "requirements": { + "yunohost": ">> 3.3.0" + }, + "multi_instance": false, + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for permissions_app" + }, + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for permissions_app" + }, + "example": "/permissions_app", + "default": "/permissions_app" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Chose a admin" + }, + "example": "johndoe" + } + ] + } +} diff --git a/permissions_app_ynh/scripts/change_url b/permissions_app_ynh/scripts/change_url new file mode 100644 index 0000000..cd35d7b --- /dev/null +++ b/permissions_app_ynh/scripts/change_url @@ -0,0 +1,24 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Stop script if errors +ynh_abort_if_errors + +# Retrive arguments +app=$YNH_APP_INSTANCE_NAME +old_domain=$YNH_APP_OLD_DOMAIN +old_path_url=$(ynh_normalize_url_path ${YNH_APP_OLD_PATH}) +domain=$YNH_APP_NEW_DOMAIN +path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH}) + +ynh_permission_del_path --app $app --permission "admin" --url "$old_domain$old_path_url/admin" +ynh_permission_del_path --app $app --permission "dev" --url "$old_domain$old_path_url/dev" + +ynh_permission_add_path --app $app --permission "admin" --url "$domain$path_url/admin" +ynh_permission_add_path --app $app --permission "dev" --url "$domain$path_url/dev" diff --git a/permissions_app_ynh/scripts/install b/permissions_app_ynh/scripts/install new file mode 100644 index 0000000..0c37820 --- /dev/null +++ b/permissions_app_ynh/scripts/install @@ -0,0 +1,27 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Stop script if errors +ynh_abort_if_errors + +# Retrieve arguments +app=$YNH_APP_INSTANCE_NAME +domain=$YNH_APP_ARG_DOMAIN +path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH) +admin_user=$YNH_APP_ARG_ADMIN + +# Check domain/path availability +ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path." +ynh_webpath_register $app $domain $path_url + +ynh_permission_create --app $app --permission "admin" --defaultdisallow --url "$domain$path_url/admin" +yunohost user permission add $app -p "admin" -u $admin_user + +ynh_permission_create --app $app --permission "dev" +ynh_permission_add_path --app $app --permission "dev" --url "$domain$path_url/dev" diff --git a/permissions_app_ynh/scripts/remove b/permissions_app_ynh/scripts/remove new file mode 100644 index 0000000..ea57cd3 --- /dev/null +++ b/permissions_app_ynh/scripts/remove @@ -0,0 +1,11 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Stop script if errors +ynh_abort_if_errors From fa4ae7734626d42688ecc0028b3020c14c970d7d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Jan 2019 21:53:48 +0100 Subject: [PATCH 2/2] url -> urls for permission_create --- permissions_app_ynh/scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/permissions_app_ynh/scripts/install b/permissions_app_ynh/scripts/install index 0c37820..048d418 100644 --- a/permissions_app_ynh/scripts/install +++ b/permissions_app_ynh/scripts/install @@ -20,7 +20,7 @@ admin_user=$YNH_APP_ARG_ADMIN ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path." ynh_webpath_register $app $domain $path_url -ynh_permission_create --app $app --permission "admin" --defaultdisallow --url "$domain$path_url/admin" +ynh_permission_create --app $app --permission "admin" --defaultdisallow --urls "$domain$path_url/admin" yunohost user permission add $app -p "admin" -u $admin_user ynh_permission_create --app $app --permission "dev"