LibrePortal/scripts/network/traefik/traefik_middlewares.sh
librelad 196b8e1dc8 refactor(traefik): per-app middleware hooks + moneyapp placeholder icon
Last app-specific bits out of central infra (from the per-app audit):

- traefik middleware: replace the hardcoded onlyoffice/owncloud exclude-list +
  onlyoffice-headers special-case (in traefik_middlewares.sh AND
  traefik_port_middlewares.sh) with two per-app hooks an app ships in
  containers/<app>/scripts/<app>_traefik.sh:
    appTraefikSkipsDefaultMiddleware_<app>  (marker: opt out of default@file)
    appTraefikExtraMiddlewares_<app>        (echo extra middleware entries)
  onlyoffice defines both; owncloud defines the skip marker. Two narrow hooks
  (not one clever one) so behavior — incl. the different onlyoffice-headers
  ordering between the two files — is preserved exactly. Verified with stubs:
  identical middleware strings across normal/onlyoffice/owncloud × authelia/wl.

- moneyapp: add a placeholder icon (geometric banknote SVG, 512x512) so it no
  longer falls back to default.svg in the WebUI.

Central traefik/compose code is now app-agnostic.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-26 01:07:14 +01:00

39 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
traefikSetupLabelsMiddlewares()
{
local app_name="$1"
local middleware_entries=()
# Default chain unless the app opts out via its per-app hook
# (containers/<app>/scripts/<app>_traefik.sh defines
# appTraefikSkipsDefaultMiddleware_<app>).
if ! declare -F "appTraefikSkipsDefaultMiddleware_${app_name}" >/dev/null 2>&1; then
middleware_entries+=("default@file")
fi
# App-specific extras (e.g. onlyoffice-headers) via the per-app hook.
if declare -F "appTraefikExtraMiddlewares_${app_name}" >/dev/null 2>&1; then
local _mw
while IFS= read -r _mw; do
[[ -n "$_mw" ]] && middleware_entries+=("$_mw")
done < <("appTraefikExtraMiddlewares_${app_name}")
fi
if [[ "$authelia_setup" == "true" && "$whitelist" == "true" ]]; then
middleware_entries+=("global-ipwhitelist@file")
if [[ $(dockerCheckAppInstalled "authelia" "docker") == "installed" ]]; then
middleware_entries+=("authelia@docker")
fi
elif [[ "$authelia_setup" == "true" && "$whitelist" == "false" ]]; then
if [[ $(dockerCheckAppInstalled "authelia" "docker") == "installed" ]]; then
middleware_entries+=("authelia@docker")
fi
elif [[ "$authelia_setup" == "false" && "$whitelist" == "true" ]]; then
middleware_entries+=("global-ipwhitelist@file")
fi
local middlewares_string="$(IFS=,; echo "${middleware_entries[*]}")"
traefik_middlewares=$middlewares_string
}