From ff15cae0a41f348960b7e539d98b3bf4df398919 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Aug 2024 19:13:19 +0000 Subject: [PATCH] Added new SSO updates to authelia.sh nextcloud.sh matrix.sh gitea.sh --- lib/authelia.sh | 2 +- lib/gitea.sh | 46 +++++++++++++++++++++++++++++++ lib/matrix.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++-- lib/nextcloud.sh | 5 ++-- 4 files changed, 118 insertions(+), 5 deletions(-) diff --git a/lib/authelia.sh b/lib/authelia.sh index f91fb5c..013b72b 100644 --- a/lib/authelia.sh +++ b/lib/authelia.sh @@ -109,7 +109,7 @@ authentication_backend: start_tls: false attributes: username: mail - display_name: cn + display_name: uid group_name: gidNumber mail: mail additional_users_dn: ou=people diff --git a/lib/gitea.sh b/lib/gitea.sh index 41d530b..aead8da 100644 --- a/lib/gitea.sh +++ b/lib/gitea.sh @@ -254,6 +254,20 @@ uninstall_gitea() { # Delete the app directory rm -rf /federated/apps/gitea + # Delete the image + docker image rm gitea/gitea:$IMAGE_VERSION &> /dev/null + + # Delete the DNS record + docker exec pdns pdnsutil delete-rrset $DOMAIN gitea A + + # Uninstall the SSO configuration if it exists in authelia (authelia must exist too) + if [[ $(grep "### Matrix" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]]; then + sed -i '/### Gitea/,/### /{/### PowerDNS/!{/### /!d}}' /federated/apps/authelia/data/config/idproviders.yml + sed -i '/### Gitea/d' /federated/apps/authelia/data/config/idproviders.yml + /federated/bin/stop authelia + /federated/bin/start authelia + fi + kill -9 $SPINPID &> /dev/null echo -ne "done.\n" } @@ -283,3 +297,35 @@ start_gitea() { echo -ne "done." } +configsso_gitea() { + [ ! -d "/federated/apps/authelia" ] && failcheck "Authelia is not installed. You need this first before continuing." + [ ! -f "/federated/apps/authelia/data/config/idproviders.yml" ] && failcheck "Authelia idproviders.yml is missing." + [[ $(grep "### Gitea" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]] && failcheck "Authelia already has a Gitea configuration." + + GITEA_CLIENT_SECRET=$(create_password); + GITEA_CLIENT_SECRET_HASH=$(docker run -it --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --password $GITEA_CLIENT_SECRET | awk '{ print $2 }') + +cat >> /federated/apps/authelia/data/config/idproviders.yml < /dev/null docker exec pdns pdnsutil add-record $DOMAIN matrix A 86400 $EXTERNALIP &> /dev/null - [ $? -ne 0 ] && fail "Couldn't add dns record" - + [ $? -ne 0 ] && fail "Couldn't add dns record for matrix" echo -ne "done." } @@ -232,6 +233,71 @@ uninstall_matrix() { # Delete the app directory rm -rf /federated/apps/matrix + # Delete the image + docker image rm matrixdotorg/synapse:$IMAGE_VERSION &> /dev/null + + # Delete the DNS record + docker exec pdns pdnsutil delete-rrset $DOMAIN matrix A + + # Uninstall the SSO configuration if it exists in authelia (authelia must exist too) + if [[ $(grep "### Matrix" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]]; then + sed -i '/### Matrix/,/### /{/### PowerDNS/!{/### /!d}}' /federated/apps/authelia/data/config/idproviders.yml + sed -i '/### Matrix/d' /federated/apps/authelia/data/config/idproviders.yml + /federated/bin/stop authelia + /federated/bin/start authelia + fi + kill -9 $SPINPID &> /dev/null echo -ne "done.\n" } +configsso_matrix() { + [ ! -d "/federated/apps/authelia" ] && failcheck "Authelia is not installed. You need this first before continuing." + [ ! -f "/federated/apps/authelia/data/config/idproviders.yml" ] && failcheck "Authelia idproviders.yml is missing." + [[ $(grep "### Matrix" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]] && failcheck "Authelia already has a Matrix configuration." + + MATRIX_CLIENT_SECRET=$(create_password); + MATRIX_CLIENT_SECRET_HASH=$(docker run -it --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --password $MATRIX_CLIENT_SECRET | awk '{ print $2 }') + +cat >> /federated/apps/authelia/data/config/idproviders.yml <> /federated/apps/matrix/data/matrix/homeserver.yaml <> /federated/apps/authelia/data/config/idproviders.yml <