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>
This commit is contained in:
@@ -152,7 +152,14 @@ What we learned:
|
|||||||
`idproviders.yml` between `### coreapp-<name> begin/end` markers (secret
|
`idproviders.yml` between `### coreapp-<name> begin/end` markers (secret
|
||||||
hashed with the running Authelia's `authelia crypto hash generate
|
hashed with the running Authelia's `authelia crypto hash generate
|
||||||
pbkdf2`), checked with `authelia validate-config` before Authelia
|
pbkdf2`), checked with `authelia validate-config` before Authelia
|
||||||
restarts (the old file is put back if the check fails). `installapp`'s
|
restarts (the old file is put back if the check fails). Like Federated's
|
||||||
|
apps, it keeps a copy in `/federated/apps/<name>/.<name>.oidc-client.yml`
|
||||||
|
(mode 600): Authelia's start (`reconcile_authelia_sso`, also
|
||||||
|
`bin/reconcile-authelia-sso`) appends any client whose copy exists but
|
||||||
|
whose first line is missing from `idproviders.yml`. So uninstalling
|
||||||
|
deletes the copy before restarting Authelia, or the client would come
|
||||||
|
back. Tested 2026-12-03: a removed block is restored by reconcile; an
|
||||||
|
uninstalled app's client stays gone `installapp`'s
|
||||||
`apply_authelia_2fa_policy` applies the Core's 2FA policy to it. The app
|
`apply_authelia_2fa_policy` applies the Core's 2FA policy to it. The app
|
||||||
reaches `https://authelia.<domain>` through traefik (`extra_hosts` to
|
reaches `https://authelia.<domain>` through traefik (`extra_hosts` to
|
||||||
traefik's address; Federated's apps use the public IP, which here would
|
traefik's address; Federated's apps use the public IP, which here would
|
||||||
@@ -197,8 +204,10 @@ Rules that follow from it:
|
|||||||
files, so each is limited to safe characters
|
files, so each is limited to safe characters
|
||||||
- Images are built outside the Core (CI in the developer's Gitea, pushed to
|
- Images are built outside the Core (CI in the developer's Gitea, pushed to
|
||||||
its container registry); the Core only pulls `image:version`
|
its container registry); the Core only pulls `image:version`
|
||||||
- Each Core picks the app's address itself (192.168.200.10-250, free on
|
- Each Core picks the app's address itself: the first free one in
|
||||||
that Core)
|
192.168.5.0/24, the range Federated's Core developer set aside for
|
||||||
|
custom apps (since 2026-12-03; apps installed in 192.168.200.x before
|
||||||
|
move on their next update)
|
||||||
- Apps live in `/federated/services/<name>/` with a `.coreapp` marker, so
|
- Apps live in `/federated/services/<name>/` with a `.coreapp` marker, so
|
||||||
Superpanel's catalog and the Core's `installapp`/`uninstallapp` see them.
|
Superpanel's catalog and the Core's `installapp`/`uninstallapp` see them.
|
||||||
That folder is Federated's git checkout; untracked folders survive
|
That folder is Federated's git checkout; untracked folders survive
|
||||||
@@ -234,6 +243,8 @@ Steps:
|
|||||||
Authelia, for admins only
|
Authelia, for admins only
|
||||||
|
|
||||||
Later:
|
Later:
|
||||||
|
- [ ] A failed update leaves the new `services/<name>/` in place with the
|
||||||
|
old container running; keep the old folder until the update works
|
||||||
- [ ] Uninstalling a need without removing the app (now refused)
|
- [ ] Uninstalling a need without removing the app (now refused)
|
||||||
- [ ] `bin/start` / `bin/stop` don't know coreapps' apps (see "Tell
|
- [ ] `bin/start` / `bin/stop` don't know coreapps' apps (see "Tell
|
||||||
Federated"); `restart: always` covers reboots
|
Federated"); `restart: always` covers reboots
|
||||||
@@ -241,6 +252,37 @@ Later:
|
|||||||
Superpanel for others
|
Superpanel for others
|
||||||
- [ ] Monitoring for published apps (dev apps aren't registered)
|
- [ ] Monitoring for published apps (dev apps aren't registered)
|
||||||
|
|
||||||
|
### Guidance from Federated's Core developer (2026-12-03)
|
||||||
|
|
||||||
|
Their points, and where coreapp-dev stands:
|
||||||
|
- Apps as `lib/<app>.sh` (config, start, uninstall, sso functions) for
|
||||||
|
`installapp`, `uninstallapp` and `installapp-sso`: not done. The
|
||||||
|
installer uses the generic `services/<app>/` format (`installGeneric`),
|
||||||
|
which `installapp` also supports. A `lib/<app>.sh` from an app's
|
||||||
|
repository would be root code from its author; the installer could
|
||||||
|
generate one from its own templates instead
|
||||||
|
- `services/<app>/service` for version, internal IP, container and image:
|
||||||
|
done
|
||||||
|
- MySQL apps use the `pdnsmysql` container (MariaDB, 192.168.0.10, also
|
||||||
|
PowerDNS's database), PostgreSQL apps `postgresql`: postgres is done;
|
||||||
|
[ ] a `mysql` need (its own user and database there)
|
||||||
|
- Authelia through `installapp-sso` / `configsso_<app>`: needs a
|
||||||
|
`lib/<app>.sh`, so not used; the sso need does the same, and keeps the
|
||||||
|
client copy Federated's apps keep
|
||||||
|
- Base directory `/federated/custom` (`custom/lib/<app>.sh`,
|
||||||
|
`custom/apps/<app>/`, `custom/services/<app>/service`): it doesn't exist
|
||||||
|
yet and no Core script knows it, so installapp, uninstallapp,
|
||||||
|
installapp-sso, start, stop, upgrade, the catalog and Superpanel (its
|
||||||
|
container mounts `/federated/apps` only) would need to learn it. Decided
|
||||||
|
2026-12-03 (David): go on with `/opt/coreapps` and today's paths, and tell
|
||||||
|
Federated what Superpanel needs later
|
||||||
|
- Internal IPs in 192.168.5.0/24: done
|
||||||
|
|
||||||
|
Superpanel lists our apps in its catalog (`catalog.json`) but not in its
|
||||||
|
installed-apps list (`applist.json`, made by
|
||||||
|
`superpanel-generate-applist-dashboard`), so they probably don't show on
|
||||||
|
its dashboard or in "Disk Usage by App". [ ] Find out why
|
||||||
|
|
||||||
### The installer in /federated/bin/coreapps/ (wanted, 2026-12-03)
|
### The installer in /federated/bin/coreapps/ (wanted, 2026-12-03)
|
||||||
|
|
||||||
David wants the installer on the Core in `/federated/bin/coreapps/`
|
David wants the installer on the Core in `/federated/bin/coreapps/`
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ The Core's own scripts trace secrets, so their output goes to
|
|||||||
nothing else, with no `{{...}}` left (`grep -r '{{' hello` prints
|
nothing else, with no `{{...}}` left (`grep -r '{{' hello` prints
|
||||||
nothing). `coreapp new hello` again refuses; so does `coreapp new x-`.
|
nothing). `coreapp new hello` again refuses; so does `coreapp new x-`.
|
||||||
2. `cd hello && coreapp deploy`: updates `/opt/coreapps` on the Core,
|
2. `cd hello && coreapp deploy`: updates `/opt/coreapps` on the Core,
|
||||||
builds, copies the image, prints `Installing hello at 192.168.200.x`
|
builds, copies the image, prints `Installing hello at 192.168.5.x`
|
||||||
(the first free address there) and `Installed: https://hello.<domain>/`.
|
(the first free address there) and `Installed: https://hello.<domain>/`.
|
||||||
On the Core, `/federated/services/hello/` has `service`,
|
On the Core, `/federated/services/hello/` has `service`,
|
||||||
`docker-compose.yml.in`, `env.in`, `install`, `uninstall`, `icon.png`,
|
`docker-compose.yml.in`, `env.in`, `install`, `uninstall`, `icon.png`,
|
||||||
@@ -258,10 +258,16 @@ has the `DB_*` variables, `.coreapp` says `needs=postgres`.
|
|||||||
4. In a browser, sign in with a Core account: the page says "Signed in as
|
4. In a browser, sign in with a Core account: the page says "Signed in as
|
||||||
..." with the account's email and groups. "Sign out" goes back to the
|
..." with the account's email and groups. "Sign out" goes back to the
|
||||||
sign-in link.
|
sign-in link.
|
||||||
5. Redeploy: still one client block, and Authelia isn't restarted
|
`/federated/apps/sso-demo/.sso-demo.oidc-client.yml` (mode 600) holds
|
||||||
|
the same block.
|
||||||
|
5. The copy restores the client: delete the block from `idproviders.yml`
|
||||||
|
(keep a backup), run `/federated/bin/reconcile-authelia-sso`: it says
|
||||||
|
"Restoring sso-demo's Authelia OIDC client" and the block is back.
|
||||||
|
6. Redeploy: still one client block, and Authelia isn't restarted
|
||||||
(`docker inspect -f '{{.State.StartedAt}}' authelia` unchanged).
|
(`docker inspect -f '{{.State.StartedAt}}' authelia` unchanged).
|
||||||
`coreapp remove`: no block, Authelia healthy, other clients (Nextcloud)
|
`coreapp remove`: no block and no copy, and running
|
||||||
still work. Deploy again: one block.
|
`/federated/bin/reconcile-authelia-sso` doesn't bring it back; Authelia
|
||||||
|
healthy, other clients (Nextcloud) still work. Deploy again: one block.
|
||||||
|
|
||||||
### With both
|
### With both
|
||||||
|
|
||||||
@@ -281,4 +287,6 @@ an empty `.coreapp` marker on the Core) moves over by replacing those files
|
|||||||
with a `coreapp.toml` with the same name, image and needs. `coreapp deploy`
|
with a `coreapp.toml` with the same name, image and needs. `coreapp deploy`
|
||||||
then updates it: same address, `.env` and data unchanged, no needs set up
|
then updates it: same address, `.env` and data unchanged, no needs set up
|
||||||
again (they're read from its `DEPENDS`), Authelia not restarted; `.coreapp`
|
again (they're read from its `DEPENDS`), Authelia not restarted; `.coreapp`
|
||||||
then says which needs it has.
|
then says which needs it has. Apps with an address outside 192.168.5.0/24
|
||||||
|
get a new one on their next update (the container moves; the app keeps
|
||||||
|
working), and apps with sign-in get their client copy.
|
||||||
|
|||||||
+17
-10
@@ -42,10 +42,11 @@ APPS = FEDERATED + "/apps"
|
|||||||
LOGS = FEDERATED + "/logs/coreapps"
|
LOGS = FEDERATED + "/logs/coreapps"
|
||||||
# Marks a services folder as made by coreapps (and holds what it set up)
|
# Marks a services folder as made by coreapps (and holds what it set up)
|
||||||
MARKER = ".coreapp"
|
MARKER = ".coreapp"
|
||||||
# Addresses for apps, away from Federated's 192.168.0.x (all in the core
|
# Addresses for apps: 192.168.5.0/24, which Federated set aside for them
|
||||||
# network's 192.168.0.0/16)
|
# (all in the core network's 192.168.0.0/16; Federated's apps are in
|
||||||
PREFIX = "192.168.200."
|
# 192.168.0.x)
|
||||||
FIRST, LAST = 10, 250
|
PREFIX = "192.168.5."
|
||||||
|
FIRST, LAST = 2, 254
|
||||||
# Hostnames on the Core that aren't apps in /federated/services or lib
|
# Hostnames on the Core that aren't apps in /federated/services or lib
|
||||||
RESERVED = {"www", "mail", "ns1", "ns2", "autodiscover", "autoconfig",
|
RESERVED = {"www", "mail", "ns1", "ns2", "autodiscover", "autoconfig",
|
||||||
"panel", "dashboard", "mcphub", "api", "admin"}
|
"panel", "dashboard", "mcphub", "api", "admin"}
|
||||||
@@ -201,10 +202,11 @@ def used_addresses():
|
|||||||
|
|
||||||
|
|
||||||
def pick_address(name):
|
def pick_address(name):
|
||||||
"""The app's address: the one it has, or the first free one."""
|
"""The app's address: the one it has, or the first free one. (Apps
|
||||||
|
from before the range moved get a new one; updating moves them.)"""
|
||||||
if is_ours(name):
|
if is_ours(name):
|
||||||
ip = service_value(os.path.join(SERVICES, name, "service"), "INTERNAL_IP")
|
ip = service_value(os.path.join(SERVICES, name, "service"), "INTERNAL_IP")
|
||||||
if ip:
|
if ip.startswith(PREFIX):
|
||||||
return ip
|
return ip
|
||||||
used = used_addresses()
|
used = used_addresses()
|
||||||
for n in range(FIRST, LAST + 1):
|
for n in range(FIRST, LAST + 1):
|
||||||
@@ -309,9 +311,10 @@ def make_service_folder(m, p, source):
|
|||||||
write(os.path.join(new, "uninstall"), fill(read_text(TEMPLATES, "uninstall"), values), 0o755)
|
write(os.path.join(new, "uninstall"), fill(read_text(TEMPLATES, "uninstall"), values), 0o755)
|
||||||
for need in m["needs"]:
|
for need in m["needs"]:
|
||||||
os.makedirs(os.path.join(new, "needs", need))
|
os.makedirs(os.path.join(new, "needs", need))
|
||||||
for step in ("setup", "teardown"):
|
for step in ("setup", "teardown", "update"):
|
||||||
write(os.path.join(new, "needs", need, step),
|
text = read_text(NEEDS_DIR, need, step)
|
||||||
fill(read_text(NEEDS_DIR, need, step), values))
|
if text:
|
||||||
|
write(os.path.join(new, "needs", need, step), fill(text, values))
|
||||||
shutil.copyfile(icon_from(source), os.path.join(new, "icon.png"))
|
shutil.copyfile(icon_from(source), os.path.join(new, "icon.png"))
|
||||||
shutil.copyfile(os.path.join(source, "coreapp.toml"), os.path.join(new, "coreapp.toml"))
|
shutil.copyfile(os.path.join(source, "coreapp.toml"), os.path.join(new, "coreapp.toml"))
|
||||||
write(os.path.join(new, MARKER),
|
write(os.path.join(new, MARKER),
|
||||||
@@ -393,7 +396,8 @@ def compose_up(m, log, recreate=False):
|
|||||||
|
|
||||||
# Run on update: the same values the generated install provides, then the
|
# Run on update: the same values the generated install provides, then the
|
||||||
# compose file again (it may have changed), settings the new version adds,
|
# compose file again (it may have changed), settings the new version adds,
|
||||||
# and the setup of needs that are new. Arguments: name, version, needs.
|
# the setup of needs that are new, and each need's update step (keeping
|
||||||
|
# what it set up current). Arguments: name, version, new needs.
|
||||||
# (service sets NAME to the app's title, so the name is also in NAME_ID.)
|
# (service sets NAME to the app's title, so the name is also in NAME_ID.)
|
||||||
UPDATE_SCRIPT = r'''
|
UPDATE_SCRIPT = r'''
|
||||||
cd /federated
|
cd /federated
|
||||||
@@ -415,6 +419,9 @@ sed -i "s/^IMAGE_VERSION=.*/IMAGE_VERSION=$2/" apps/$1/.env
|
|||||||
chmod 600 apps/$1/.env
|
chmod 600 apps/$1/.env
|
||||||
shift 2
|
shift 2
|
||||||
for need in "$@"; do . services/$NAME_ID/needs/$need/setup; done
|
for need in "$@"; do . services/$NAME_ID/needs/$need/setup; done
|
||||||
|
for step in services/$NAME_ID/needs/*/update; do
|
||||||
|
if [ -e "$step" ]; then . "$step"; fi
|
||||||
|
done
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ cat >> "$IDP" <<OIDC
|
|||||||
OIDC
|
OIDC
|
||||||
if docker exec authelia authelia validate-config > /dev/null 2>&1; then
|
if docker exec authelia authelia validate-config > /dev/null 2>&1; then
|
||||||
rm -f "$IDP.coreapp-{{NAME}}.bak"
|
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
|
restart_service authelia
|
||||||
else
|
else
|
||||||
echo "Authelia rejected the new client; left its configuration as it was." >&2
|
echo "Authelia rejected the new client; left its configuration as it was." >&2
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
# Remove its OpenID Connect client from the Core's Authelia
|
# Remove its OpenID Connect client from the Core's Authelia. The copy goes
|
||||||
|
# first: Authelia's start (reconcile_authelia_sso) would add the client back
|
||||||
|
# from it
|
||||||
|
rm -f /federated/apps/{{NAME}}/.{{NAME}}.oidc-client.yml
|
||||||
sed -i '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/d' \
|
sed -i '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/d' \
|
||||||
/federated/apps/authelia/data/config/idproviders.yml
|
/federated/apps/authelia/data/config/idproviders.yml
|
||||||
restart_service authelia
|
restart_service authelia
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Keep the copy of its Authelia client current (apps installed before
|
||||||
|
# copies were kept get one); Authelia's start restores clients from these
|
||||||
|
IDP=/federated/apps/authelia/data/config/idproviders.yml
|
||||||
|
COPY=/federated/apps/{{NAME}}/.{{NAME}}.oidc-client.yml
|
||||||
|
if grep -qx ' ### coreapp-{{NAME}} begin' "$IDP"; then
|
||||||
|
sed -n '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/p' "$IDP" > "$COPY"
|
||||||
|
chmod 600 "$COPY"
|
||||||
|
fi
|
||||||
|
unset IDP COPY
|
||||||
@@ -9,6 +9,6 @@ installGeneric {{NAME}}
|
|||||||
chmod 600 /federated/apps/{{NAME}}/.env
|
chmod 600 /federated/apps/{{NAME}}/.env
|
||||||
# What the app needs from the Core (its database, its sign-in client)
|
# What the app needs from the Core (its database, its sign-in client)
|
||||||
for setup in /federated/services/{{NAME}}/needs/*/setup; do
|
for setup in /federated/services/{{NAME}}/needs/*/setup; do
|
||||||
[ -e "$setup" ] && . "$setup"
|
if [ -e "$setup" ]; then . "$setup"; fi
|
||||||
done
|
done
|
||||||
unset setup
|
unset setup
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# the Core, delete its settings and data.
|
# the Core, delete its settings and data.
|
||||||
docker compose -f /federated/apps/{{NAME}}/docker-compose.yml -p {{NAME}} down
|
docker compose -f /federated/apps/{{NAME}}/docker-compose.yml -p {{NAME}} down
|
||||||
for teardown in /federated/services/{{NAME}}/needs/*/teardown; do
|
for teardown in /federated/services/{{NAME}}/needs/*/teardown; do
|
||||||
[ -e "$teardown" ] && . "$teardown"
|
if [ -e "$teardown" ]; then . "$teardown"; fi
|
||||||
done
|
done
|
||||||
unset teardown
|
unset teardown
|
||||||
rm -rf /federated/apps/{{NAME}}
|
rm -rf /federated/apps/{{NAME}}
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ step and tell you what happened.
|
|||||||
|
|
||||||
Common causes:
|
Common causes:
|
||||||
|
|
||||||
- "doesn't answer at http://192.168.200.x:PORT/...": the app crashed (see
|
- "doesn't answer at http://192.168.5.x:PORT/...": the app crashed (see
|
||||||
`coreapp logs`), listens on another port or on 127.0.0.1, or `health`
|
`coreapp logs`), listens on another port or on 127.0.0.1, or `health`
|
||||||
points at a path that fails or redirects to an error.
|
points at a path that fails or redirects to an error.
|
||||||
- `coreapp check` fails but deploy worked: a new certificate can take a
|
- `coreapp check` fails but deploy worked: a new certificate can take a
|
||||||
|
|||||||
Reference in New Issue
Block a user