From 5ac9d7d3a3f793f93f8fbc93f4a0416edace6587 Mon Sep 17 00:00:00 2001 From: kload Date: Thu, 17 Oct 2013 11:37:27 +0000 Subject: [PATCH] Bugfixes --- action_map.yml | 22 +++++++++------------- yunohost_domain.py | 44 ++++++++++++++++++++++++++++++++++++++++++-- yunohost_tools.py | 37 ------------------------------------- 3 files changed, 51 insertions(+), 52 deletions(-) diff --git a/action_map.yml b/action_map.yml index 3400cb60..15f8844c 100644 --- a/action_map.yml +++ b/action_map.yml @@ -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 diff --git a/yunohost_domain.py b/yunohost_domain.py index b3f38ad7..88aacc6d 100644 --- a/yunohost_domain.py +++ b/yunohost_domain.py @@ -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 diff --git a/yunohost_tools.py b/yunohost_tools.py index 99ae1a4e..ebffe1b4 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -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