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:
parent
e0072ab1cf
commit
fdd5b7f396
3 changed files with 26 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
server_name = sys.argv[1]
|
server_name = sys.argv[1]
|
||||||
domain = sys.argv[2]
|
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:
|
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
|
||||||
data = json.load(jsonFile)
|
data = json.load(jsonFile)
|
||||||
|
|
||||||
|
if "skipped_urls" not in data:
|
||||||
|
data["skipped_urls"] = []
|
||||||
|
if "protected_urls" not in data:
|
||||||
|
data["protected_urls"] = []
|
||||||
|
|
||||||
# Remove entry without the domain specified
|
# Remove entry without the domain specified
|
||||||
|
if "/_matrix" in data["skipped_urls"]:
|
||||||
data["skipped_urls"].remove("/_matrix")
|
data["skipped_urls"].remove("/_matrix")
|
||||||
|
|
||||||
if "skipped_urls" in data and "/_matrix" not in data:
|
if domain + "/_matrix" not in data["skipped_urls"]:
|
||||||
data["skipped_urls"] += [domain + "/_matrix", server_name + "/.well-known/matrix/"]
|
data["skipped_urls"].append(domain + "/_matrix")
|
||||||
else:
|
if server_name + "/.well-known/matrix/" not in data["skipped_urls"]:
|
||||||
data["skipped_urls"] = [domain + "/_matrix", server_name + "/.well-known/matrix/"]
|
data["skipped_urls"].append(server_name + "/.well-known/matrix/")
|
||||||
if "protected_urls" in data and domain + "/_matrix/cas_server.php/login" not in data:
|
|
||||||
|
if domain + "/_matrix/cas_server.php/login" not in data["protected_urls"]:
|
||||||
data["protected_urls"].append(domain + "/_matrix/cas_server.php/login")
|
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:
|
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
|
||||||
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
|
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
server_name = sys.argv[1]
|
|
||||||
domain = sys.argv[2]
|
|
||||||
|
|
||||||
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
|
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
|
||||||
data = json.load(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:
|
if "/_matrix" in entry or "/.well-known/matrix/" in entry:
|
||||||
data["skipped_urls"].remove(entry)
|
data["skipped_urls"].remove(entry)
|
||||||
for entry in data["protected_urls"]:
|
|
||||||
|
for entry in data["protected_urls"].copy():
|
||||||
if "/_matrix" in entry:
|
if "/_matrix" in entry:
|
||||||
data["protected_urls"].remove(entry)
|
data["protected_urls"].remove(entry)
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,13 @@ fi
|
||||||
ynh_store_file_checksum --file="$homeserver_config_path"
|
ynh_store_file_checksum --file="$homeserver_config_path"
|
||||||
ynh_store_file_checksum --file="/etc/matrix-$app/log.yaml"
|
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
|
# RELOAD SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue