1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00

Fix SSO script

This commit is contained in:
Josué Tille 2020-03-17 22:02:59 +01:00
parent e0072ab1cf
commit fdd5b7f396
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
3 changed files with 26 additions and 14 deletions

View file

@ -1,4 +1,5 @@
import json
import sys
server_name = sys.argv[1]
domain = sys.argv[2]
@ -6,17 +7,22 @@ domain = sys.argv[2]
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
# Remove entry without the domain specified
data["skipped_urls"].remove("/_matrix")
if "skipped_urls" not in data:
data["skipped_urls"] = []
if "protected_urls" not in data:
data["protected_urls"] = []
if "skipped_urls" in data and "/_matrix" not in data:
data["skipped_urls"] += [domain + "/_matrix", server_name + "/.well-known/matrix/"]
else:
data["skipped_urls"] = [domain + "/_matrix", server_name + "/.well-known/matrix/"]
if "protected_urls" in data and domain + "/_matrix/cas_server.php/login" not in data:
# Remove entry without the domain specified
if "/_matrix" in data["skipped_urls"]:
data["skipped_urls"].remove("/_matrix")
if domain + "/_matrix" not in data["skipped_urls"]:
data["skipped_urls"].append(domain + "/_matrix")
if server_name + "/.well-known/matrix/" not in data["skipped_urls"]:
data["skipped_urls"].append(server_name + "/.well-known/matrix/")
if domain + "/_matrix/cas_server.php/login" not in data["protected_urls"]:
data["protected_urls"].append(domain + "/_matrix/cas_server.php/login")
else:
data["protected_urls"] = [domain + "/_matrix/cas_server.php/login"]
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,14 +1,13 @@
import json
server_name = sys.argv[1]
domain = sys.argv[2]
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
for entry in data["skipped_urls"]:
for entry in data["skipped_urls"].copy():
if "/_matrix" in entry or "/.well-known/matrix/" in entry:
data["skipped_urls"].remove(entry)
for entry in data["protected_urls"]:
for entry in data["protected_urls"].copy():
if "/_matrix" in entry:
data["protected_urls"].remove(entry)

View file

@ -137,6 +137,13 @@ fi
ynh_store_file_checksum --file="$homeserver_config_path"
ynh_store_file_checksum --file="/etc/matrix-$app/log.yaml"
#=================================================
# SETUP SSOWAT
#=================================================
python3 ../conf/remove_sso_conf.py
python3 ../conf/add_sso_conf.py $domain $server_name || ynh_die --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. Please fix the syntax to install this app. For more information see here: https://github.com/YunoHost-Apps/synapse_ynh/issues/32"
#=================================================
# RELOAD SERVICES
#=================================================