Files
coreapp-dev/core/needs/sso/setup
T
davidandClaude Opus 5.5 89585e81aa Apps get 192.168.5.0/24; keep a copy of each Authelia client
Addresses now come from 192.168.5.0/24, the range Federated's Core
developer set aside for custom apps. Apps installed in 192.168.200.x get
a new address on their next update.

Like Federated's apps, the sso need keeps a copy of its Authelia client in
/federated/apps/<name>/.<name>.oidc-client.yml, so Authelia's start
(reconcile_authelia_sso) restores it if Authelia is reinstalled. Removing
an app deletes the copy before restarting Authelia, which would otherwise
add the client back. Needs can have an update step, run on every update;
sso's writes the copy for apps installed before this.

Fixed: an update of an app with no needs failed at its end (a test that
found nothing to run set the exit status), leaving the app on its old
address.

PLAN.md: the Core developer's guidance and where coreapp-dev stands on
each point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 14:10:43 -07:00

48 lines
2.0 KiB
Plaintext

# 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" <<OIDC
### coreapp-{{NAME}} begin
- client_id: 'coreapp-{{NAME}}'
client_name: '{{TITLE}}'
client_secret: '$OIDC_HASH'
consent_mode: 'implicit'
public: false
authorization_policy: 'one_factor'
require_pkce: true
pkce_challenge_method: 'S256'
redirect_uris:
- 'https://{{NAME}}.$DOMAIN/auth/callback'
scopes:
- 'openid'
- 'profile'
- 'email'
- 'groups'
response_types:
- 'code'
grant_types:
- 'authorization_code'
token_endpoint_auth_method: 'client_secret_basic'
userinfo_signed_response_alg: 'none'
### coreapp-{{NAME}} end
OIDC
if docker exec authelia authelia validate-config > /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