echo6-docs/vault/runbooks/headscale-oidc-boot-order.md
echo6-autocommit ef8b1e0bd9 auto: docs sync 2026-07-13T12:00:23+00:00
Files changed: engine/.embcache.json engine/changelog.md engine/lint-report.md vault/.trash/2026-06-19.md vault/docs/hardware/environment.md vault/docs/hardware/ip-allocation.md vault/docs/matrix/archivist.md vault/docs/matrix/matrix_host.md vault/docs/matrix/mautrix_signal.md vault/docs/matrix/synapse.md vault/docs/matrix/synapse_retention_discovery.md vault/docs/navi/cc-rules.md vault/docs/navi/deployment.md vault/docs/navi/themes.md vault/docs/services/ots-setup.md vault/docs/services/services.md vault/docs/services/usenet.md vault/docs/software/authentik.md vault/docs/software/caddy.md vault/docs/software/central.md vault/docs/software/dns.md vault/docs/software/geo-tools.md vault/docs/software/navi.md vault/docs/software/recon.md vault/docs/software/searxng.md vault/glossary.md vault/notes/echo6-landing-page-data-export.md vault/notes/ia-download-queue.md vault/projects/advbbs-project.md vault/projects/argus.md vault/projects/deploy-livesync.md vault/projects/fleet-patch-audit.md vault/projects/fleet-platform-baseline.md vault/projects/matrix-synapse-deployment.md vault/projects/meshai-config-hot-apply.md vault/projects/meshai-region-routing-plan.md vault/projects/meshai.md vault/projects/meshcore-transport.md vault/projects/meshtastic-headscale-runbook.md vault/projects/mmud-project.md vault/projects/nominatim-v5-reimport.md vault/runbooks/add-peertube-channel.md vault/runbooks/authentik-access-groups.md vault/runbooks/authentik-create-invitation.md vault/runbooks/authentik-oidc-application.md vault/runbooks/authentik-upgrade.md vault/runbooks/central-deploy-cutover.md vault/runbooks/ct-runbook.md vault/runbooks/edge2-access-reference.md vault/runbooks/expose-service-contabo.md vault/runbooks/expose-service-edge2.md vault/runbooks/expose-service-home.md vault/runbooks/fleet-magicdns-resolved-migration.md vault/runbooks/headless-browser-page-verification.md vault/runbooks/headscale-oidc-boot-order.md vault/runbooks/headscale-onboard-node.md vault/runbooks/ia-cli-reference.md vault/runbooks/ia-download-mirror.md vault/runbooks/idahomesh-bridge-setup.md vault/runbooks/idahomesh-vpn-device-setup.md vault/runbooks/lxc-service-migration.md vault/runbooks/mailcow-create-mailbox.md vault/runbooks/meshai-prod-compose-override.md vault/runbooks/meshmonitor-password-reset.md vault/runbooks/meshtastic-sidecar-node.md vault/runbooks/meshtasticd-sim-nodes-runbook.md vault/runbooks/nordvpn-lxc.md vault/runbooks/peertube-remote-runner.md vault/runbooks/pg-backup.md vault/runbooks/pi-nas-omv-runbook.md vault/runbooks/pipeline-patterns.md vault/runbooks/proxmox-create-ubuntu-vm.md vault/runbooks/proxmox-onboard-node.md vault/runbooks/pymc-repeater-kiss-tnc-reenumeration.md vault/runbooks/recon-operations.md vault/runbooks/recon-service-integration.md vault/runbooks/syncthing-add-node.md vault/runbooks/toc-cortex-pve9.2-update.md vault/session-resume/SESSION-HANDOFF-meshai-test.md
2026-07-13 12:00:23 +00:00

4.6 KiB

title type tags aliases related updated
Headscale — OIDC Disabled at Boot (Authentik Boot-Order Dependency) runbook
auth
authentik-oidc-application
headscale-onboard-node
authentik
authentik-upgrade
fleet-magicdns-resolved-migration
2026-07-13

Headscale — OIDC Disabled at Boot (Authentik Boot-Order Dependency)

Headscale wires up its OIDC provider once, at process startup, by fetching authentik's discovery document. If Authentik is unreachable at that moment, Headscale silently falls back to CLI-only auth and runs OIDC-disabled until it is restarted. This is a boot-ordering hazard: the fleet Headscale (edge2 CT107) and Authentik (edge2 CT105, auth.echo6.co) live on the same host, so an edge2 reboot — or the DNS-bootstrap window after one — can bring Headscale up before Authentik is serving.

Symptom

  • A client (especially the Tailscale Android app on a GrapheneOS phone) hits Connect and lands on Headscale's manual node-registration page (the "run headscale nodes register ..." screen) instead of being redirected to Authentik for SSO login.
  • New nodes can't self-register via SSO; only the preauth-key / CLI path works.
  • vpn.echo6.co/health still returns pass — the service is up, it's just running without OIDC. The failure is silent.

Root cause

The Headscale config sets only_start_if_oidc_is_available: false, so Headscale boots even when OIDC discovery fails. When Authentik was unreachable at startup, the log shows:

WRN failed to set up OIDC provider, falling back to CLI based authentication
    error="creating OIDC provider from issuer config: 502 Bad Gateway"

From that point the running process serves only manual/CLI registration — even after Authentik recovers — because OIDC is initialized only at startup, never retried.

Diagnosis

Access path: ssh edge2 (admin) then sudo pct exec 107 -- docker exec headscale headscale <cmd>. See edge2-access-reference.

# 1. Is OIDC currently broken? Look for the 502 / fallback warning since the container started:
ssh edge2 "sudo pct exec 107 -- docker logs headscale --since 48h 2>&1 | grep -iE 'oidc|502|fallback'"

# 2. Is Authentik discovery healthy NOW (from inside CT107)?
ssh edge2 "sudo pct exec 107 -- curl -fsS --max-time 8 \
  https://auth.echo6.co/application/o/headscale/.well-known/openid-configuration \
  -o /dev/null -w 'HTTP %{http_code}\n'"

If step 1 shows the fallback warning AND step 2 returns HTTP 200, OIDC is recoverable by a restart.

Fix

Restart the Headscale container so it re-initializes the OIDC provider against now-healthy Authentik:

ssh edge2 "sudo pct exec 107 -- docker restart headscale"

Verify the fix:

# Fallback warning should be GONE this start (only the benign 'listening without TLS' WRN is expected):
ssh edge2 "sudo pct exec 107 -- docker logs headscale --since 3m 2>&1 | grep -iE 'oidc|502|fallback|warn'"

# Health + fleet intact:
curl -fsS https://vpn.echo6.co/health         # -> {"status":"pass"}
ssh edge2 "sudo pct exec 107 -- docker exec headscale headscale nodes list | grep -c 100.64.0"   # ~34+ nodes

Then have the client hit Connect again — it should now redirect to Authentik (silently, if the device's browser already holds a live auth.echo6.co SSO session).

Impact of the restart: low. Existing WireGuard tunnels stay up (no node drops off the tailnet); only control-plane coordination pauses for a few seconds. Headscale is lockout-critical — drive the restart only from the edge2 out-of-band path above, never over vpn.echo6.co itself.

Prevention / follow-up

  • The failure is silent (health stays green), so it recurs on any future edge2/Authentik restart-ordering hiccup. Candidate hardening: a health-gated watchdog that restarts Headscale when the logs show the OIDC fallback warning while Authentik discovery returns 200; or a systemd boot-order/ExecStartPre gate so Headscale waits for Authentik discovery before starting.
  • After any edge2 reboot, treat "can a fresh client SSO-register?" as a post-reboot check — not just vpn.echo6.co/health.

Reference incident

  • 2026-06-30 — GrapheneOS phone reauth landed on the manual-registration page. Headscale had booted ~11h earlier (during an edge2 reboot / DNS-bootstrap window) while Authentik was 502'ing, so OIDC was disabled. Restarting the headscale container restored OIDC; the phone then registered via Authentik (silent SSO) as user matt. Onboarding control-server path also corrected in headscale-onboard-node the same day.