mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Add/remove access for apps
This commit is contained in:
parent
ed2f051fb0
commit
02e6c5843a
2 changed files with 23 additions and 34 deletions
|
@ -270,6 +270,7 @@ app:
|
||||||
-r:
|
-r:
|
||||||
full: --raw
|
full: --raw
|
||||||
help: Return the full app_dict
|
help: Return the full app_dict
|
||||||
|
action: store_true
|
||||||
|
|
||||||
### app_map()
|
### app_map()
|
||||||
map:
|
map:
|
||||||
|
@ -317,21 +318,6 @@ app:
|
||||||
full: --file
|
full: --file
|
||||||
help: Folder or tarball for upgrade
|
help: Folder or tarball for upgrade
|
||||||
|
|
||||||
### app_info() TODO: Write help
|
|
||||||
info:
|
|
||||||
action_help: Get app informations
|
|
||||||
api: GET /app
|
|
||||||
arguments:
|
|
||||||
app:
|
|
||||||
help: App ID
|
|
||||||
-i:
|
|
||||||
full: --instance
|
|
||||||
help: App instance number
|
|
||||||
-r:
|
|
||||||
full: --raw
|
|
||||||
help: Return the full app_dict
|
|
||||||
action: store_true
|
|
||||||
|
|
||||||
### app_setting()
|
### app_setting()
|
||||||
setting:
|
setting:
|
||||||
action_help: Set ou get an app setting value
|
action_help: Set ou get an app setting value
|
||||||
|
|
|
@ -33,7 +33,7 @@ import time
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
from yunohost import YunoHostError, YunoHostLDAP, win_msg, random_password, is_true, validate
|
from yunohost import YunoHostError, YunoHostLDAP, win_msg, random_password, is_true, validate
|
||||||
from yunohost_domain import domain_list, domain_add
|
from yunohost_domain import domain_list, domain_add, domain_ssowatconf
|
||||||
from yunohost_user import user_info
|
from yunohost_user import user_info
|
||||||
from yunohost_hook import hook_exec
|
from yunohost_hook import hook_exec
|
||||||
|
|
||||||
|
@ -180,12 +180,11 @@ def app_info(app, raw=False):
|
||||||
if raw:
|
if raw:
|
||||||
return app_info
|
return app_info
|
||||||
else:
|
else:
|
||||||
return [
|
return {
|
||||||
('Name', app_info['manifest']['name']),
|
'Name': app_info['manifest']['name'],
|
||||||
('Version', app_info['manifest']['version']),
|
'Description': app_info['manifest']['description']['en'],
|
||||||
('Description', app_info['manifest']['description']),
|
|
||||||
#TODO: Add more infos
|
#TODO: Add more infos
|
||||||
]
|
}
|
||||||
|
|
||||||
|
|
||||||
def app_map(app=None, raw=False):
|
def app_map(app=None, raw=False):
|
||||||
|
@ -413,7 +412,11 @@ def app_addaccess(apps, users):
|
||||||
with open(apps_setting_path + app +'/settings.yml') as f:
|
with open(apps_setting_path + app +'/settings.yml') as f:
|
||||||
app_settings = yaml.load(f)
|
app_settings = yaml.load(f)
|
||||||
|
|
||||||
if 'mode' in app_settings and app_settings['mode'] == 'private':
|
if 'mode' not in app_settings:
|
||||||
|
app_setting(app, 'mode', 'private')
|
||||||
|
app_settings['mode'] = 'private'
|
||||||
|
|
||||||
|
if app_settings['mode'] == 'private':
|
||||||
if 'allowed_users' in app_settings:
|
if 'allowed_users' in app_settings:
|
||||||
new_users = app_settings['allowed_users']
|
new_users = app_settings['allowed_users']
|
||||||
else:
|
else:
|
||||||
|
@ -425,14 +428,14 @@ def app_addaccess(apps, users):
|
||||||
user_info(allowed_user)
|
user_info(allowed_user)
|
||||||
except YunoHostError:
|
except YunoHostError:
|
||||||
continue
|
continue
|
||||||
|
if new_users == '':
|
||||||
|
new_users = allowed_user
|
||||||
|
else:
|
||||||
new_users = new_users +','+ allowed_user
|
new_users = new_users +','+ allowed_user
|
||||||
|
|
||||||
app_settings['allowed_users'] = new_users.strip()
|
app_setting(app, 'allowed_users', new_users.strip())
|
||||||
with open(apps_setting_path + app +'/settings.yml', 'w') as f:
|
|
||||||
yaml.safe_dump(app_settings, f, default_flow_style=False)
|
|
||||||
win_msg(_("App setting file updated"))
|
|
||||||
|
|
||||||
#TODO: Regenerate SSOwat conf
|
domain_ssowatconf()
|
||||||
|
|
||||||
|
|
||||||
def app_removeaccess(apps, users):
|
def app_removeaccess(apps, users):
|
||||||
|
@ -461,14 +464,14 @@ def app_removeaccess(apps, users):
|
||||||
if 'allowed_users' in app_settings:
|
if '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 == '':
|
||||||
|
new_users = allowed_user
|
||||||
|
else:
|
||||||
new_users = new_users +','+ allowed_user
|
new_users = new_users +','+ allowed_user
|
||||||
|
|
||||||
app_settings['allowed_users'] = new_users.strip()
|
app_setting(app, 'allowed_users', new_users.strip())
|
||||||
with open(apps_setting_path + app +'/settings.yml', 'w') as f:
|
|
||||||
yaml.safe_dump(app_settings, f, default_flow_style=False)
|
|
||||||
win_msg(_("App setting file updated"))
|
|
||||||
|
|
||||||
#TODO: Regenerate SSOwat conf
|
domain_ssowatconf()
|
||||||
|
|
||||||
|
|
||||||
def app_setting(app, key, value=None):
|
def app_setting(app, key, value=None):
|
||||||
|
|
Loading…
Reference in a new issue