Merge pull request #3 from YunoHost/permission_app

Create app to check the permissions
This commit is contained in:
Alexandre Aubin 2019-05-17 20:18:54 +02:00 committed by GitHub
commit b463916116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1 @@

View file

@ -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"
}
]
}
}

View file

@ -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"

View file

@ -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 --urls "$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"

View file

@ -0,0 +1,11 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors