diff --git a/ct/authentik.sh b/ct/authentik.sh new file mode 100644 index 0000000..9f43a99 --- /dev/null +++ b/ct/authentik.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# Authentik — zentraler Homelab-IdP (nexus ADR-0003) +# +# Creates an unprivileged Debian 12 LXC with nesting enabled that runs the +# official Authentik docker-compose stack (server, worker, postgres, redis). +# +# Automation-friendly by design (nexus-hub K-102): +# - bootstrap admin password AND API token are generated headlessly +# (-> /root/authentik.credentials) so an agent can apply blueprints via +# API without ever touching the UI +# - optional dedicated SSH public key for agent access (Claude Code) +# - blueprints dir mounted at /opt/authentik/blueprints (compose override) +# +# Manual steps that remain AFTER this script (by design): +# 1. NPMplus: proxy host auth. -> http://:9000 +# (WebSockets ON; the auth domain is PERMANENT — WebAuthn RP-ID!) +# 2. Passkey enrollment of the human admin account +# +# Run on a Proxmox VE host: +# bash -c "$(curl -fsSL https://gitea.luki-net.org/luki-net/proxmox-scripts/raw/branch/main/ct/authentik.sh)" + +set -euo pipefail + +APP="authentik" +APP_DESCRIPTION="Authentik IdP (Docker-Compose) — Passkeys, TOTP, OIDC für nexus & Homelab" +APP_PORT="${APP_PORT:-9000}" + +LIB_URL="${LIB_URL:-https://gitea.luki-net.org/luki-net/proxmox-scripts/raw/branch/main/lib}" +INSTALL_SCRIPT_URL="${INSTALL_SCRIPT_URL:-https://gitea.luki-net.org/luki-net/proxmox-scripts/raw/branch/main/install/authentik-install.sh}" + +# LXC defaults (server+worker+postgres+redis brauchen Luft) +DEFAULT_HOSTNAME="authentik" +DEFAULT_DISK="20" +DEFAULT_CORES="2" +DEFAULT_RAM="4096" + +prompt_app_config() { + echo + echo "── Authentik configuration ─────────────────────────────────" + if [[ -z "${AUTH_DOMAIN:-}" ]]; then + read -rp "Auth-Domain (dauerhaft! WebAuthn-RP-ID), z. B. auth.luki-net.org: " AUTH_DOMAIN + fi + [[ -n "${AUTH_DOMAIN:-}" ]] || { msg_err "AUTH_DOMAIN ist Pflicht"; exit 1; } + if [[ -z "${CLAUDE_SSH_PUBKEY:-}" ]]; then + read -rp "SSH-Public-Key für Agent-Zugang (leer = überspringen): " CLAUDE_SSH_PUBKEY || true + fi + # Authentik-Version: leer = Default des offiziellen Compose-Files + AUTHENTIK_TAG="${AUTHENTIK_TAG:-}" + echo " → domain: $AUTH_DOMAIN port: $APP_PORT tag: ${AUTHENTIK_TAG:-compose-default}" +} + +push_app_config() { + msg_info "Pushing config into container..." + local tmpf; tmpf=$(mktemp) + cat >"$tmpf" </dev/null 2>&1 && break + sleep 2 + done + msg_ok "Container restarted with nesting enabled" +} + +print_app_summary() { + cat <