From d915628bd7b5aaaaf24944bec6da2d6d3130b565 Mon Sep 17 00:00:00 2001 From: zamentur Date: Mon, 9 Feb 2015 23:03:51 +0100 Subject: [PATCH] [enh] Add app settings to redirect request --- actionsmap/yunohost.yml | 5 ++--- app.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/actionsmap/yunohost.yml b/actionsmap/yunohost.yml index 0713448b2..21fad7d90 100644 --- a/actionsmap/yunohost.yml +++ b/actionsmap/yunohost.yml @@ -554,9 +554,8 @@ app: listmodules: action_help: List all web admin modules api: GET /modules - configuration: - authenticate: - authenticator: ldap-anonymous + configuration: + authenticate: false ############################# # Backup # diff --git a/app.py b/app.py index f3a35365e..8b5b33d4a 100644 --- a/app.py +++ b/app.py @@ -757,12 +757,15 @@ def app_setting(app, key, value=None, delete=False): if app_settings is not None and key in app_settings: return app_settings[key] else: + yaml_settings=['redirected_urls','redirected_regex'] # Set the value if app_settings is None: app_settings = {} if delete and key in app_settings: del app_settings[key] else: + if key in yaml_settings: + value=yaml.load(value) app_settings[key] = value with open(settings_file, 'w') as f: @@ -890,7 +893,7 @@ def app_ssowatconf(auth): protected_urls = [] protected_regex = [] redirected_regex = { main_domain +'/yunohost[\/]?$': 'https://'+ main_domain +'/yunohost/sso/' } - + redirected_urls ={} apps = {} try: apps_list = app_list()['apps'] @@ -922,9 +925,10 @@ def app_ssowatconf(auth): if item[-1:] == '/': item = item[:-1] protected_urls.append(app_settings['domain'] + app_settings['path'][:-1] + item) - if 'protected_regex' in app_settings: - for item in app_settings['protected_regex'].split(','): - protected_regex.append(item) + if 'redirected_urls' in app_settings: + redirected_urls.update(app_settings['redirected_urls']) + if 'redirected_regex' in app_settings: + redirected_regex.update(app_settings['redirected_regex']) for domain in domains: skipped_urls.extend(['/yunohost/admin', '/yunohost/api']) @@ -945,6 +949,7 @@ def app_ssowatconf(auth): 'skipped_regex': skipped_regex, 'unprotected_regex': unprotected_regex, 'protected_regex': protected_regex, + 'redirected_urls': redirected_urls, 'redirected_regex': redirected_regex, 'users': users, }