mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
SSOwat conf generator tool
This commit is contained in:
parent
50cfb9bce8
commit
060c4c76bb
2 changed files with 50 additions and 1 deletions
|
@ -637,3 +637,13 @@ tools:
|
||||||
--dyndns:
|
--dyndns:
|
||||||
help: Subscribe domain to a DynDNS service
|
help: Subscribe domain to a DynDNS service
|
||||||
action: store_true
|
action: store_true
|
||||||
|
|
||||||
|
### tools_ssowatconf()
|
||||||
|
ssowatconf:
|
||||||
|
action_help: Regenerate SSOwat configuration file
|
||||||
|
api: PUT /ssowatconf
|
||||||
|
arguments:
|
||||||
|
-r:
|
||||||
|
full: --returns
|
||||||
|
help: Return boolean
|
||||||
|
action: store_true
|
||||||
|
|
|
@ -32,7 +32,7 @@ import subprocess
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from yunohost import YunoHostError, YunoHostLDAP, validate, colorize, get_required_args, win_msg
|
from yunohost import YunoHostError, YunoHostLDAP, validate, colorize, get_required_args, win_msg
|
||||||
from yunohost_domain import domain_add
|
from yunohost_domain import domain_add, domain_list
|
||||||
from yunohost_dyndns import dyndns_subscribe
|
from yunohost_dyndns import dyndns_subscribe
|
||||||
from yunohost_backup import backup_init
|
from yunohost_backup import backup_init
|
||||||
|
|
||||||
|
@ -278,3 +278,42 @@ def tools_postinstall(domain, password, dyndns=False):
|
||||||
os.system('service samba restart')
|
os.system('service samba restart')
|
||||||
|
|
||||||
win_msg(_("YunoHost has been successfully configured"))
|
win_msg(_("YunoHost has been successfully configured"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def tools_ssowatconf(returns=False):
|
||||||
|
"""
|
||||||
|
Regenerate SSOwat conf from YunoHost settings
|
||||||
|
|
||||||
|
Keyword argument:
|
||||||
|
Returns
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open('/etc/yunohost/current_host', 'r') as f:
|
||||||
|
main_domain = f.readline().rstrip()
|
||||||
|
|
||||||
|
domains = domain_list()['Domains']
|
||||||
|
|
||||||
|
conf_dict = {
|
||||||
|
'portal_domain': main_domain,
|
||||||
|
'portal_path': '/sso/',
|
||||||
|
'portal_port': '443',
|
||||||
|
'portal_scheme': 'https',
|
||||||
|
'additional_headers': {
|
||||||
|
'Auth-User': 'uid',
|
||||||
|
'Remote-User': 'uid',
|
||||||
|
'Name': 'cn',
|
||||||
|
'Email': 'mail'
|
||||||
|
},
|
||||||
|
'domains': domains,
|
||||||
|
'skipped_urls': [],
|
||||||
|
'unprotected_urls': []
|
||||||
|
}
|
||||||
|
|
||||||
|
with open('/etc/ssowat/conf.json', 'wb') as f:
|
||||||
|
json.dump(conf_dict, f)
|
||||||
|
|
||||||
|
win_msg(_('SSOwat configuration generated'))
|
||||||
|
|
||||||
|
if returns:
|
||||||
|
return True
|
||||||
|
|
Loading…
Add table
Reference in a new issue