# Register it with the Core's Authelia as an OpenID Connect client, with the # secret from .env (hashed), between markers so uninstall can remove it. # Safe to run again. Authelia is checked with the new client before it # restarts; if the check fails, its old configuration is put back. IDP=/federated/apps/authelia/data/config/idproviders.yml OIDC_CLIENT_SECRET="$(sed -n 's/^OIDC_CLIENT_SECRET=//p' /federated/apps/{{NAME}}/.env)" OIDC_HASH="$(docker exec authelia authelia crypto hash generate pbkdf2 --password "$OIDC_CLIENT_SECRET" | awk '/Digest:/ {print $2}')" cp -p "$IDP" "$IDP.coreapp-{{NAME}}.bak" sed -i '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/d' "$IDP" cat >> "$IDP" < /dev/null 2>&1; then rm -f "$IDP.coreapp-{{NAME}}.bak" # A copy of the client, as Federated's apps keep: if Authelia is ever # reinstalled, its start (reconcile_authelia_sso) adds it back sed -n '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/p' "$IDP" \ > /federated/apps/{{NAME}}/.{{NAME}}.oidc-client.yml chmod 600 /federated/apps/{{NAME}}/.{{NAME}}.oidc-client.yml restart_service authelia else echo "Authelia rejected the new client; left its configuration as it was." >&2 mv "$IDP.coreapp-{{NAME}}.bak" "$IDP" fi unset IDP OIDC_CLIENT_SECRET OIDC_HASH