From e6ccb01af18f9b174a92ee8a30fb143d0c9143fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 3 Apr 2020 23:23:05 +0200 Subject: [PATCH] Print warning if packager try to show tile for regex and disable show tile in this case --- locales/en.json | 1 + src/yunohost/app.py | 2 +- src/yunohost/permission.py | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 30ede23a8..cacf8282e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -501,6 +501,7 @@ "regenconf_dry_pending_applying": "Checking pending configuration which would have been applied for category '{category}'…", "regenconf_failed": "Could not regenerate the configuration for category(s): {categories}", "regenconf_pending_applying": "Applying pending configuration for category '{category}'…", + "regex_incompatible_with_tile": "/!\\ Packagers! You for the permission '{permission}' can't set the regex {regex} as main url and set 'show_tile' to 'true'", "regex_with_only_domain": "You can't use a regex for domain, only for path", "restore_already_installed_app": "An app with the ID '{app:s}' is already installed", "restore_app_failed": "Could not restore the app '{app:s}'", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index d72e439bb..0263a9d98 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1325,7 +1325,7 @@ def app_ssowatconf(): permissions[perm_name] = { "users": perm_info['corresponding_users'], "label": perm_info['label'], - "show_tile": perm_info['show_tile'], + "show_tile": perm_info['show_tile'] if not perm_info["url"].startswith('re:') else False, "auth_header": perm_info['auth_header'], "public": "visitors" in perm_info["allowed"], "uris": uris diff --git a/src/yunohost/permission.py b/src/yunohost/permission.py index 1dcdc176d..2ea12b508 100644 --- a/src/yunohost/permission.py +++ b/src/yunohost/permission.py @@ -167,6 +167,9 @@ def user_permission_update(operation_logger, permission, add=None, remove=None, if "visitors" not in new_allowed_groups or len(new_allowed_groups) >= 3: logger.warning(m18n.n("permission_currently_allowed_for_all_users")) + if existing_permission['url'].startswith('re:') and show_tile: + logger.warning(m18n.n('regex_incompatible_with_tile', regex=existing_permission['url'], permission=permission)) + # Commit the new allowed group list operation_logger.start() @@ -351,6 +354,8 @@ def permission_url(operation_logger, permission, url = _check_and_normalize_permission_path(url) domain, path = _get_full_url(url, app_main_path).split('/', 1) conflicts = _get_conflicting_apps(domain, path, ignore_app=permission.spit('.')[0]) + if url.startswith('re:') and existing_permission['show_tile']: + logger.warning(m18n.n('regex_incompatible_with_tile', regex=url, permission=permission)) if conflicts: apps = [] @@ -547,7 +552,6 @@ def _update_ldap_group_permission(permission, allowed, if show_tile is None: show_tile = existing_permission["show_tile"] - # TODO set show_tile to False if url is regex if protected is None: protected = existing_permission["protected"]