From 25bb354d14edb76492a654a9a45ae8b4cb4da17c Mon Sep 17 00:00:00 2001 From: mbugeia Date: Wed, 18 Mar 2015 17:34:29 +0100 Subject: [PATCH] Improve sso config Former-commit-id: 5ef86ebac458aaff3e8854d09a144cec326c8973 --- conf/add_sso_conf.py | 11 +++++++++++ conf/remove_sso_conf.py | 8 ++++++++ scripts/install | 7 +++++-- scripts/remove | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 conf/add_sso_conf.py create mode 100644 conf/remove_sso_conf.py diff --git a/conf/add_sso_conf.py b/conf/add_sso_conf.py new file mode 100644 index 0000000..5c43e4f --- /dev/null +++ b/conf/add_sso_conf.py @@ -0,0 +1,11 @@ +import json + +with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: + data = json.load(jsonFile) + if "unprotected_urls" in data: + data["unprotected_urls"].append("/seafhttp") + else: + data["unprotected_urls"] = ["/seafhttp"] + +with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: + jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/conf/remove_sso_conf.py b/conf/remove_sso_conf.py new file mode 100644 index 0000000..a29c367 --- /dev/null +++ b/conf/remove_sso_conf.py @@ -0,0 +1,8 @@ +import json + +with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: + data = json.load(jsonFile) + data["unprotected_urls"].remove("/seafhttp") + +with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: + jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/scripts/install b/scripts/install index 960643d..22deb22 100644 --- a/scripts/install +++ b/scripts/install @@ -129,8 +129,11 @@ sudo yunohost firewall allow $seafile_port sudo su - www-data -c "/var/www/seafile/seafile-server-4.0.6/seafile.sh start" sudo su - www-data -c "$final_path/first_launch.exp $admin_email $admin_password" -#sudo yunohost app setting seafile skipped_urls -v "/media" -#sudo yunohost app setting seafile unprotected_urls -v "/" +# add sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent +sudo python ../conf/add_sso_config.py + +# unprotect media +sudo yunohost app setting seafile unprotected_uris -v "/media" if [ "$is_public" = "No" ] then diff --git a/scripts/remove b/scripts/remove index 5764426..baf02a7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,6 +20,9 @@ sudo yunohost firewall disallow $seafile_port sudo yunohost service remove seafile-server +# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent +sudo python ../conf/remove_sso_config.py + # Restart services sudo service nginx reload sudo yunohost app ssowatconf \ No newline at end of file