From a0ce7c2d28ebba2df27bba2e7e5064c99533f310 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 7 Oct 2023 17:40:06 +0200 Subject: [PATCH] ssowatconf: drop unused redirected_regex mechanism + we don't need the label+show_tile info in ssowat conf anymore --- src/app.py | 28 ++------------------------ src/utils/legacy.py | 49 --------------------------------------------- 2 files changed, 2 insertions(+), 75 deletions(-) diff --git a/src/app.py b/src/app.py index eca528682..adcea56e4 100644 --- a/src/app.py +++ b/src/app.py @@ -1619,8 +1619,6 @@ def app_ssowatconf(): permissions = { "core_skipped": { "users": [], - "label": "Core permissions - skipped", - "show_tile": False, "auth_header": False, "public": True, "uris": [domain + "/yunohost/admin" for domain in domains] @@ -1635,11 +1633,6 @@ def app_ssowatconf(): } } - # FIXME : what's the reason we do this only for the maindomain ? x_X - redirected_regex = { - main_domain + r"/yunohost[\/]?$": "https://" + main_domain + "/yunohost/sso/" - } - redirected_urls = {} apps_using_remote_user_var_in_nginx = ( check_output( @@ -1649,19 +1642,8 @@ def app_ssowatconf(): .split("\n") ) - for app in _installed_apps(): - app_settings = read_yaml(APPS_SETTING_PATH + app + "/settings.yml") or {} - - # Redirected - redirected_urls.update(app_settings.get("redirected_urls", {})) - redirected_regex.update(app_settings.get("redirected_regex", {})) - - from .utils.legacy import ( - translate_legacy_default_app_in_ssowat_conf_json_persistent, - ) - - translate_legacy_default_app_in_ssowat_conf_json_persistent() - + # FIXME : this could be handled by nginx's regen conf to further simplify ssowat's code ... + redirected_urls = {} for domain in domains: default_app = domain_config_get(domain, "feature.app.default_app") if default_app != "_none" and _is_installed(default_app): @@ -1691,10 +1673,6 @@ def app_ssowatconf(): "use_remote_user_var_in_nginx_conf": app_id in apps_using_remote_user_var_in_nginx, "users": perm_info["corresponding_users"], - "label": perm_info["label"], - "show_tile": perm_info["show_tile"] - and perm_info["url"] - and (not perm_info["url"].startswith("re:")), "auth_header": perm_info["auth_header"], "public": "visitors" in perm_info["allowed"], "uris": uris, @@ -1703,9 +1681,7 @@ def app_ssowatconf(): conf_dict = { "cookie_secret_file": "/etc/yunohost/.ssowat_cookie_secret", "cookie_name": "yunohost.portal", - "theme": settings_get("misc.portal.portal_theme"), "redirected_urls": redirected_urls, - "redirected_regex": redirected_regex, "domain_portal_urls": _get_domain_portal_dict(), "permissions": permissions, } diff --git a/src/utils/legacy.py b/src/utils/legacy.py index af9c08b98..4f11d28d7 100644 --- a/src/utils/legacy.py +++ b/src/utils/legacy.py @@ -114,55 +114,6 @@ def legacy_permission_label(app, permission_type): ) -def translate_legacy_default_app_in_ssowat_conf_json_persistent(): - from yunohost.app import app_list - from yunohost.domain import domain_config_set - - persistent_file_name = "/etc/ssowat/conf.json.persistent" - if not os.path.exists(persistent_file_name): - return - - # Ugly hack because for some reason so many people have tabs in their conf.json.persistent ... - os.system(r"sed -i 's/\t/ /g' /etc/ssowat/conf.json.persistent") - - # Ugly hack to try not to misarably fail migration - persistent = read_yaml(persistent_file_name) - - if "redirected_urls" not in persistent: - return - - redirected_urls = persistent["redirected_urls"] - - if not any( - from_url.count("/") == 1 and from_url.endswith("/") - for from_url in redirected_urls - ): - return - - apps = app_list()["apps"] - - if not any(app.get("domain_path") in redirected_urls.values() for app in apps): - return - - for from_url, dest_url in redirected_urls.copy().items(): - # Not a root domain, skip - if from_url.count("/") != 1 or not from_url.endswith("/"): - continue - for app in apps: - if app.get("domain_path") != dest_url: - continue - domain_config_set(from_url.strip("/"), "feature.app.default_app", app["id"]) - del redirected_urls[from_url] - - persistent["redirected_urls"] = redirected_urls - - write_to_json(persistent_file_name, persistent, sort_keys=True, indent=4) - - logger.warning( - "YunoHost automatically translated some legacy redirections in /etc/ssowat/conf.json.persistent to match the new default application using domain configuration" - ) - - LEGACY_PHP_VERSION_REPLACEMENTS = [ ("/etc/php5", "/etc/php/8.2"), ("/etc/php/7.0", "/etc/php/8.2"),