This commit is contained in:
kload 2013-10-17 11:37:27 +00:00
parent 0665b84259
commit 5ac9d7d3a3
3 changed files with 51 additions and 52 deletions

View file

@ -180,10 +180,6 @@ domain:
help: Domain name to add
nargs: '+'
pattern: '^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$'
-r:
full: --raw
help: Auto-configure Apache and LemonLDAP for the domain
action: store_true
### domain_remove()
remove:
@ -204,6 +200,15 @@ domain:
help: ""
pattern: '^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$'
### domain_ssowatconf()
ssowatconf:
action_help: Regenerate SSOwat configuration file
api: PUT /ssowatconf
arguments:
-r:
full: --returns
help: Return boolean
action: store_true
#############################
# App #
@ -638,12 +643,3 @@ tools:
help: Subscribe domain to a DynDNS service
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

View file

@ -28,9 +28,9 @@ import sys
import datetime
import re
import shutil
import json
from urllib import urlopen
from yunohost import YunoHostError, YunoHostLDAP, win_msg, colorize, validate, get_required_args
from yunohost_tools import tools_ssowatconf
def domain_list(filter=None, limit=None, offset=None):
@ -198,7 +198,7 @@ def domain_add(domains, main=False):
raise YunoHostError(169, _("An error occured during domain creation"))
tools_ssowatconf()
domain_ssowatconf()
win_msg(_("Domain(s) successfully created"))
@ -245,6 +245,46 @@ def domain_remove(domains):
else:
raise YunoHostError(169, _("An error occured during domain deletion"))
domain_ssowatconf()
win_msg(_("Domain(s) successfully deleted"))
return { 'Domains' : result }
def domain_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

View file

@ -280,40 +280,3 @@ def tools_postinstall(domain, password, dyndns=False):
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