mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
app_removeaccess()
This commit is contained in:
parent
1ef16ca925
commit
0e8ea0d2ee
4 changed files with 48 additions and 5 deletions
|
@ -316,10 +316,10 @@ app:
|
||||||
removeaccess:
|
removeaccess:
|
||||||
action_help: Revoke access right to users (everyone by default)
|
action_help: Revoke access right to users (everyone by default)
|
||||||
arguments:
|
arguments:
|
||||||
app:
|
apps:
|
||||||
nargs: "+"
|
nargs: "+"
|
||||||
-u:
|
-u:
|
||||||
full: --user
|
full: --users
|
||||||
nargs: "+"
|
nargs: "+"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,7 @@ def lemon_configuration(conf_dict):
|
||||||
lemon_conf.write(conf_line + '\n')
|
lemon_conf.write(conf_line + '\n')
|
||||||
|
|
||||||
if os.system('/usr/share/lemonldap-ng/bin/lmYnhMoulinette') == 0:
|
if os.system('/usr/share/lemonldap-ng/bin/lmYnhMoulinette') == 0:
|
||||||
|
os.system('service apache2 reload')
|
||||||
win_msg(_("LemonLDAP configured"))
|
win_msg(_("LemonLDAP configured"))
|
||||||
else:
|
else:
|
||||||
raise YunoHostError(1, _("An error occured during LemonLDAP configuration"))
|
raise YunoHostError(1, _("An error occured during LemonLDAP configuration"))
|
||||||
|
|
|
@ -419,14 +419,57 @@ def app_addaccess(apps, users):
|
||||||
|
|
||||||
for allowed_user in users:
|
for allowed_user in users:
|
||||||
if allowed_user not in new_users.split(' '):
|
if allowed_user not in new_users.split(' '):
|
||||||
|
# TODO: check if user exists
|
||||||
new_users = new_users +' '+ allowed_user
|
new_users = new_users +' '+ allowed_user
|
||||||
|
|
||||||
app_settings['allowed_users'] = new_users
|
app_settings['allowed_users'] = new_users.strip()
|
||||||
with open(apps_setting_path + installed_app +'/app_settings.yml', 'w') as f:
|
with open(apps_setting_path + installed_app +'/app_settings.yml', 'w') as f:
|
||||||
yaml.safe_dump(app_settings, f, default_flow_style=False)
|
yaml.safe_dump(app_settings, f, default_flow_style=False)
|
||||||
win_msg(_("App setting file updated"))
|
win_msg(_("App setting file updated"))
|
||||||
|
|
||||||
lemon_conf_lines[('locationRules', app_settings['domain'], '(?#'+ installed_app +'Z)^'+ app_settings['path'] )] = 'grep( /^$uid$/, qw('+ new_users +'))'
|
lemon_conf_lines[('locationRules', app_settings['domain'], '(?#'+ installed_app +'Z)^'+ app_settings['path'] )] = 'grep( /^$uid$/, qw('+ new_users.strip() +'))'
|
||||||
|
|
||||||
|
lemon_configuration(lemon_conf_lines)
|
||||||
|
|
||||||
|
|
||||||
|
def app_removeaccess(apps, users):
|
||||||
|
"""
|
||||||
|
Revoke access to a private app to a user
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
apps -- List of app to revoke access to
|
||||||
|
users -- Users to revoke access for
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not isinstance(users, list): users = [users]
|
||||||
|
if not isinstance(apps, list): apps = [apps]
|
||||||
|
|
||||||
|
installed_apps = os.listdir(apps_setting_path)
|
||||||
|
|
||||||
|
lemon_conf_lines = {}
|
||||||
|
|
||||||
|
for installed_app in installed_apps:
|
||||||
|
for app in apps:
|
||||||
|
new_users = ''
|
||||||
|
if '__' not in app:
|
||||||
|
app = app + '__1'
|
||||||
|
|
||||||
|
if app == installed_app:
|
||||||
|
with open(apps_setting_path + installed_app +'/app_settings.yml') as f:
|
||||||
|
app_settings = yaml.load(f)
|
||||||
|
|
||||||
|
if app_settings['mode'] == 'private':
|
||||||
|
if 'allowed_users' in app_settings:
|
||||||
|
for allowed_user in app_settings['allowed_users'].split(' '):
|
||||||
|
if allowed_user not in users:
|
||||||
|
new_users = new_users +' '+ allowed_user
|
||||||
|
|
||||||
|
app_settings['allowed_users'] = new_users.strip()
|
||||||
|
with open(apps_setting_path + installed_app +'/app_settings.yml', 'w') as f:
|
||||||
|
yaml.safe_dump(app_settings, f, default_flow_style=False)
|
||||||
|
win_msg(_("App setting file updated"))
|
||||||
|
|
||||||
|
lemon_conf_lines[('locationRules', app_settings['domain'], '(?#'+ installed_app +'Z)^'+ app_settings['path'] )] = 'grep( /^$uid$/, qw('+ new_users.strip() +'))'
|
||||||
|
|
||||||
lemon_configuration(lemon_conf_lines)
|
lemon_configuration(lemon_conf_lines)
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,6 @@ def domain_add(domains, web=False):
|
||||||
('vhostOptions', domain, 'vhostPort'): -1,
|
('vhostOptions', domain, 'vhostPort'): -1,
|
||||||
('vhostOptions', domain, 'vhostHttps'): -1,
|
('vhostOptions', domain, 'vhostHttps'): -1,
|
||||||
('locationRules', domain, 'default'): 'accept',
|
('locationRules', domain, 'default'): 'accept',
|
||||||
('locationRules', domain, '(?#logout)^/logout'): 'logout_app_sso https://'+ domain +'/'
|
|
||||||
})
|
})
|
||||||
_apache_config(domain)
|
_apache_config(domain)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue