[enh] Add app settings to redirect request

This commit is contained in:
zamentur 2015-02-09 23:03:51 +01:00
parent 6f5bac8eca
commit d915628bd7
2 changed files with 11 additions and 7 deletions

View file

@ -555,8 +555,7 @@ app:
action_help: List all web admin modules
api: GET /modules
configuration:
authenticate:
authenticator: ldap-anonymous
authenticate: false
#############################
# Backup #

13
app.py
View file

@ -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,
}