This commit is contained in:
2024-01-11 11:07:37 -06:00
parent 18aa6ce61d
commit c24fb6debe
6 changed files with 113 additions and 86 deletions

View File

@@ -54,7 +54,7 @@ DELSITE(){
echo
fi
[ "${NM_AUTHELIA_IP}" != "" ] && ssh root@${NM_AUTHELIA_IP} sed -i "/${DEL_SITE}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
[ "${NM_AUTHELIA_IP}" != "" ] && ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} sed -i "/${DEL_SITE}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
SERVICE_MGMT nginx restart
@@ -139,7 +139,7 @@ NEWSITE(){
exit 0
elif [[ ${overwrite} =~ ^[Yy]$ ]]; then
rm -f ${nginxconfig} >/dev/null 2>&1
[ "${NM_AUTHELIA_IP}" != "" ] && ssh root@${NM_AUTHELIA_IP} sed -i "/${MAIN_SITE}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
[ "${NM_AUTHELIA_IP}" != "" ] && ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} sed -i "/${MAIN_SITE}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
else
exit 0
fi
@@ -282,12 +282,12 @@ NEWSITE(){
echo -e "${idsCL[LightGreen]}Configuring Authelia SSO for '${idsCL[Yellow]}${MAIN_SITE}${idsCL[LightGreen]}' {${NGINX_SERVERNAME}}...${idsCL[Default]}"
if [ "${SECURE}" == "2FA" ]; then
ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies needing 2 factor below/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies needing 2 factor below/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
else
ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
fi
ssh root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh root@${NM_AUTHELIA_IP} "/usr/bin/docker restart authelia >/dev/null 2>&1"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "/usr/bin/docker restart authelia >/dev/null 2>&1"
fi
######################################### LOCAL
@@ -474,20 +474,20 @@ NEWPROXYSITE_CREATE(){
if [[ "${SECURE}" = *"FA"* ]]; then
echo -en "${idsCL[LightCyan]}Enabling ${SECURE} SSO access ... "
sed -i "s/#include conf.d\/include\/secure-access.conf/include conf.d\/include\/secure-access.conf/g" ${nginxconfig}
ssh root@${NM_AUTHELIA_IP} sed -i "/${SITENAME}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} sed -i "/${SITENAME}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
if [ "${SECURE}" == "2FA" ]; then
ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies needing 2 factor below/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies needing 2 factor below/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
else
ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${MAIN_SITE}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
fi
ssh root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh root@${NM_AUTHELIA_IP} "/usr/bin/docker restart authelia >/dev/null 2>&1"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "/usr/bin/docker restart authelia >/dev/null 2>&1"
echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}"
echo
else
echo -en "${idsCL[LightCyan]}Disabling SSO access ... "
sed -i "s/include conf.d\/include\/secure-access.conf/#include conf.d\/include\/secure-access.conf/g" ${nginxconfig}
[ "${NM_AUTHELIA_IP}" != "" ] && ssh root@${NM_AUTHELIA_IP} sed -i "/${SITENAME}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
[ "${NM_AUTHELIA_IP}" != "" ] && ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} sed -i "/${SITENAME}/d" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml
echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}"
echo
fi
@@ -557,7 +557,7 @@ SITEINFO(){
done
if [ "${onefacline}" == "" ]; then
[ "$(${NCMD} ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | awk '/inet/ {print $2}' | cut -d'/' -f1)" != "${NM_AUTHELIA_IP}" ] && ACMD="ssh root@${NM_AUTHELIA_IP}" || ACMD=""
[ "$(${NCMD} ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | awk '/inet/ {print $2}' | cut -d'/' -f1)" != "${NM_AUTHELIA_IP}" ] && ACMD="ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP}" || ACMD=""
autheliaconfig=$(${ACMD} cat ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml)
onefacline=$(echo "${autheliaconfig}" | grep -Fn one_factor | sort | tail -n1)
onefacline=${onefacline%%:*}
@@ -627,8 +627,8 @@ SITEINFO(){
sitefacline=${sitefacline%%:*}
if [ "${sitefacline}" == "" ]; then
SECURE='error'
# ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${SITENAME}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
# ssh root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
# ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${SITENAME}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
# ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml"
elif [ ${sitefacline} -lt ${onefacline} ]; then
SECURE='1FA'
elif [ ${sitefacline} -lt ${twofacline} ]; then