Add/remove access bugfix (closes #93 and closes #94)

This commit is contained in:
kload 2014-03-03 13:49:18 +01:00
parent 67af5a68e9
commit fed6718b4a

View file

@ -528,7 +528,11 @@ def app_addaccess(apps, users):
apps apps
""" """
#TODO: Adapt to SSOwat if not users:
users = []
for user in user_list()['Users']:
users.append(user['Username'])
if not isinstance(users, list): users = [users] if not isinstance(users, list): users = [users]
if not isinstance(apps, list): apps = [apps] if not isinstance(apps, list): apps = [apps]
@ -564,6 +568,8 @@ def app_addaccess(apps, users):
app_ssowatconf() app_ssowatconf()
return { 'allowed_users': new_users.split(',') }
def app_removeaccess(apps, users): def app_removeaccess(apps, users):
""" """
@ -574,7 +580,9 @@ def app_removeaccess(apps, users):
apps apps
""" """
#TODO: Remove access remove_all = False
if not users:
remove_all = True
if not isinstance(users, list): users = [users] if not isinstance(users, list): users = [users]
if not isinstance(apps, list): apps = [apps] if not isinstance(apps, list): apps = [apps]
for app in apps: for app in apps:
@ -587,7 +595,9 @@ def app_removeaccess(apps, users):
app_settings = yaml.load(f) app_settings = yaml.load(f)
if 'skipped_uris' not in app_settings or app_settings['skipped_uris'] != '/': if 'skipped_uris' not in app_settings or app_settings['skipped_uris'] != '/':
if 'allowed_users' in app_settings: if remove_all:
new_users = ''
elif 'allowed_users' in app_settings:
for allowed_user in app_settings['allowed_users'].split(','): for allowed_user in app_settings['allowed_users'].split(','):
if allowed_user not in users: if allowed_user not in users:
if new_users == '': if new_users == '':
@ -606,6 +616,7 @@ def app_removeaccess(apps, users):
app_ssowatconf() app_ssowatconf()
return { 'allowed_users': new_users.split(',') }
def app_setting(app, key, value=None, delete=False): def app_setting(app, key, value=None, delete=False):
""" """