mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
This is a list of url so should be called 'urls'
This commit is contained in:
parent
6054e4eb3c
commit
022d3922c1
3 changed files with 14 additions and 14 deletions
|
@ -28,26 +28,26 @@ ynh_app_setting_delete() {
|
||||||
|
|
||||||
# Create a new permission for the app
|
# Create a new permission for the app
|
||||||
#
|
#
|
||||||
# usage: ynh_permission_create --app "app" --permission "permission" --defaultdisallow [--url "url" ["url" ...]]
|
# usage: ynh_permission_create --app "app" --permission "permission" --defaultdisallow [--urls "url" ["url" ...]]
|
||||||
# | arg: app - the application id
|
# | arg: app - the application id
|
||||||
# | arg: permission - the name for the permission (by default a permission named "main" already exist)
|
# | arg: permission - the name for the permission (by default a permission named "main" already exist)
|
||||||
# | arg: defaultdisallow - define if all user will be allowed by default
|
# | arg: defaultdisallow - define if all user will be allowed by default
|
||||||
# | arg: url - the url for the the permission
|
# | arg: urls - the list of urls for the the permission
|
||||||
ynh_permission_create() {
|
ynh_permission_create() {
|
||||||
declare -Ar args_array=( [a]=app= [p]=permission= [d]=defaultdisallow [u]=url= )
|
declare -Ar args_array=( [a]=app= [p]=permission= [d]=defaultdisallow [u]=urls= )
|
||||||
local app
|
local app
|
||||||
local permission
|
local permission
|
||||||
local defaultdisallow
|
local defaultdisallow
|
||||||
local url
|
local urls
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
if [[ -n ${defaultdisallow:-} ]]; then
|
if [[ -n ${defaultdisallow:-} ]]; then
|
||||||
defaultdisallow=",default_allow=False"
|
defaultdisallow=",default_allow=False"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${url:-} ]]; then
|
if [[ -n ${urls:-} ]]; then
|
||||||
url=",url=['${url//';'/"','"}']"
|
urls=",urls=['${urls//';'/"','"}']"
|
||||||
fi
|
fi
|
||||||
yunohost tools shell -c "from yunohost.permission import permission_add; permission_add(auth, '$app', '$permission' ${defaultdisallow:-} ${url:-}, sync_perm=False)"
|
yunohost tools shell -c "from yunohost.permission import permission_add; permission_add(auth, '$app', '$permission' ${defaultdisallow:-} ${urls:-}, sync_perm=False)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove a permission for the app (note that when the app is removed all permission is automatically removed)
|
# Remove a permission for the app (note that when the app is removed all permission is automatically removed)
|
||||||
|
|
|
@ -76,7 +76,7 @@ def migrate_app_permission(auth, app=None):
|
||||||
url = None
|
url = None
|
||||||
if domain and path:
|
if domain and path:
|
||||||
url = domain + path
|
url = domain + path
|
||||||
permission_add(auth, app, 'main', url=url, default_allow=True, sync_perm=False)
|
permission_add(auth, app, 'main', urls=[url], default_allow=True, sync_perm=False)
|
||||||
if permission:
|
if permission:
|
||||||
allowed_group = permission.split(',')
|
allowed_group = permission.split(',')
|
||||||
user_permission_add(auth, [app], 'main', group=allowed_group, sync_perm=False)
|
user_permission_add(auth, [app], 'main', group=allowed_group, sync_perm=False)
|
||||||
|
|
|
@ -312,14 +312,14 @@ def user_permission_clear(operation_logger, auth, app=[], permission=None, sync_
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation(['permission','app'])
|
@is_unit_operation(['permission','app'])
|
||||||
def permission_add(operation_logger, auth, app, permission, url=None, default_allow=True, sync_perm=True):
|
def permission_add(operation_logger, auth, app, permission, urls=None, default_allow=True, sync_perm=True):
|
||||||
"""
|
"""
|
||||||
Create a new permission for a specific application
|
Create a new permission for a specific application
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
app -- an application OR sftp, xmpp (metronome), mail
|
app -- an application OR sftp, xmpp (metronome), mail
|
||||||
permission -- name of the permission ("main" by default)
|
permission -- name of the permission ("main" by default)
|
||||||
url -- list of url to specify for the permission
|
urls -- list of urls to specify for the permission
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import _normalize_domain_path
|
from yunohost.domain import _normalize_domain_path
|
||||||
|
@ -348,11 +348,11 @@ def permission_add(operation_logger, auth, app, permission, url=None, default_al
|
||||||
if default_allow:
|
if default_allow:
|
||||||
attr_dict['groupPermission'] = 'cn=all_users,ou=groups,dc=yunohost,dc=org'
|
attr_dict['groupPermission'] = 'cn=all_users,ou=groups,dc=yunohost,dc=org'
|
||||||
|
|
||||||
if url:
|
if urls:
|
||||||
attr_dict['URL'] = []
|
attr_dict['URL'] = []
|
||||||
for u in url:
|
for url in urls:
|
||||||
domain = u[:u.index('/')]
|
domain = url[:url.index('/')]
|
||||||
path = u[u.index('/'):]
|
path = url[url.index('/'):]
|
||||||
domain, path = _normalize_domain_path(domain, path)
|
domain, path = _normalize_domain_path(domain, path)
|
||||||
attr_dict['URL'].append(domain + path)
|
attr_dict['URL'].append(domain + path)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue