Upstream config fix

This commit is contained in:
cortex
2026-05-24 11:10:16 +01:00
parent 56e97b9ead
commit ae5154ee51
2 changed files with 15 additions and 1 deletions
+14 -1
View File
@@ -100,11 +100,14 @@ log_info "Linking Synapse and MAS via OIDC..."
CLIENT_ID="synapse-client"
CLIENT_SECRET=$(openssl rand -hex 32)
ADMIN_SECRET=$(openssl rand -hex 32)
MATRIX_ENDPOINT="http://synapse:8008"
EXISTING_CLIENT=$(yq '.clients[] | select(.client_id == "'"${CLIENT_ID}"'")' "$MAS_CFG" 2>/dev/null || echo "")
if [[ -z "$EXISTING_CLIENT" ]]; then
CLIENT_OBJ="{
\"client_id\": \"${CLIENT_ID}\",
\"client_auth_method\": \"client_secret_basic\",
\"client_secret\": \"${CLIENT_SECRET}\",
\"redirect_uris\": [\"https://${HOMESERVER_FQDN}/_synapse/client/oidc/callback\"],
\"grant_types\": [\"authorization_code\", \"refresh_token\"],
@@ -112,12 +115,22 @@ if [[ -z "$EXISTING_CLIENT" ]]; then
\"scopes\": [\"openid\", \"profile\", \"email\"],
\"application_type\": \"web\"
}"
yq -y -i ".clients += [$CLIENT_OBJ]" "$SYNAPSE_CFG" || { log_error "Failed to register Synapse client in MAS"; exit 1; }
yq -y -i ".clients += [$CLIENT_OBJ]" "$MAS_CFG" || { log_error "Failed to register Synapse client in MAS"; exit 1; }
log_info " -> Registered Synapse as OIDC client in MAS"
else
log_info " -> Synapse client already registered in MAS, skipping"
fi
# Ensure the matrix section exists
if ! yq '.matrix' "$MAS_CFG" > /dev/null 2>&1; then
yq -y -i '.matrix = {}' "$MAS_CFG"
fi
yq -y -i ".matrix.homeserver = \"${HOMESERVER_FQDN}\"" "$MAS_CFG"
yq -y -i ".matrix.secret = \"${MATRIX_SECRET}\"" "$MAS_CFG"
yq -y -i ".matrix.endpoint = \"${MATRIX_ENDPOINT}\"" "$MAS_CFG"
ISSUER_URL="https://${MAS_FQDN}"
fix_ownership "$SYNAPSE_CFG"