Deprecate (un)protected_uris and _regex settings + more explicit deprecation warning for app_add/remove/clearaccess

This commit is contained in:
Alexandre Aubin 2019-09-15 18:10:58 +02:00
parent 8abfd2a6e6
commit c4743398e6
2 changed files with 11 additions and 1 deletions

View file

@ -176,6 +176,8 @@ else:
elif action == "set":
if key in ['redirected_urls', 'redirected_regex']:
value = yaml.load(value)
if key in ["unprotected_uris", "unprotected_regex", "protected_uris", "protected_regex"]:
logger.warning("/!\\ Packagers ! This app is using the legacy permission system. Please delete these legacy settings and use the new helpers ynh_permission_{create,urls,update,delete} and the 'visitors' group to manage public/private access.")
settings[key] = value
else:
raise ValueError("action should either be get, set or delete")
@ -249,7 +251,7 @@ ynh_permission_create() {
# Remove a permission for the app (note that when the app is removed all permission is automatically removed)
#
# usage: ynh_permission_remove --permission "permission"
# usage: ynh_permission_delete --permission "permission"
# | arg: permission - the name for the permission (by default a permission named "main" is removed automatically when the app is removed)
#
# example: ynh_permission_delete --permission editors

View file

@ -1037,6 +1037,8 @@ def app_addaccess(apps, users=[]):
"""
from yunohost.permission import user_permission_update
logger.warning("/!\\ Packagers ! This app is using the legacy permission system. Please use the new helpers ynh_permission_{create,urls,update,delete} and the 'visitors' group to manage permissions.")
output = {}
for app in apps:
permission = user_permission_update(app+".main", add=users)
@ -1056,6 +1058,8 @@ def app_removeaccess(apps, users=[]):
"""
from yunohost.permission import user_permission_update
logger.warning("/!\\ Packagers ! This app is using the legacy permission system. Please use the new helpers ynh_permission_{create,urls,update,delete} and the 'visitors' group to manage permissions.")
output = {}
for app in apps:
permission = user_permission_update(app+".main", remove=users)
@ -1074,6 +1078,8 @@ def app_clearaccess(apps):
"""
from yunohost.permission import user_permission_reset
logger.warning("/!\\ Packagers ! This app is using the legacy permission system. Please use the new helpers ynh_permission_{create,urls,update,delete} and the 'visitors' group to manage permissions.")
output = {}
for app in apps:
permission = user_permission_reset(app+".main")
@ -1181,6 +1187,8 @@ def app_setting(app, key, value=None, delete=False):
# FIXME: Allow multiple values for some keys?
if key in ['redirected_urls', 'redirected_regex']:
value = yaml.load(value)
if key in ["unprotected_uris", "unprotected_regex", "protected_uris", "protected_regex"]:
logger.warning("/!\ Packagers ! This app is using the legacy permission system. Please delete these legacy settings and use the new helpers ynh_permission_{create,urls,update,delete} and the 'visitors' group to manage public/private access.")
app_settings[key] = value
_set_app_settings(app, app_settings)