electric-horses-infra/stacks/forgejo
Benjamin Weinlich 09925f7eda docs(adr): add ADR-0007 on OIDC avatar data-URL gotcha
When a new user logs in via Authentik OIDC for the first time,
Forgejo tries to fetch the 'picture' claim as an avatar — but
Authentik delivers a 'data:image/svg+xml;base64,...' URL that
Forgejo can't store. Result: DB has an avatar hash but no file,
so /avatars/<hash> returns 404, the <img> is in broken state,
and the activity page's canvas renderer crashes with
'drawImage on broken state'.

Fix (per user, after first login):
  UPDATE "user" SET avatar = '', use_custom_avatar = false
  WHERE lower_name = '<name>';

Triggers Forgejo's default identicon generation, which works.

This commit:
- Adds ADR-0007 with full root cause + three rejected alternatives
- Updates docs/adr/README.md index
- Extends stacks/forgejo/Agent.md 'Known Gotchas' with the fix
- Appends the fix to docs/runbooks/forgejo-admin-recovery.md

Applied for user 'bw' already on 2026-04-12.

Refs OP#1119
2026-04-12 04:47:25 +02:00
..
.env.example feat(stacks/forgejo): add self-hosted Git stack 2026-04-11 22:19:25 +02:00
Agent.md docs(adr): add ADR-0007 on OIDC avatar data-URL gotcha 2026-04-12 04:47:25 +02:00
backup.sh feat(stacks/forgejo): add self-hosted Git stack 2026-04-11 22:19:25 +02:00
docker-compose.yml feat(stacks/forgejo): add self-hosted Git stack 2026-04-11 22:19:25 +02:00
README.md feat(stacks/forgejo): add self-hosted Git stack 2026-04-11 22:19:25 +02:00

Forgejo — Self-Hosted Git

Live: https://code.sdda.eu Git SSH: ssh://git@code.sdda.eu:222/<user>/<repo>.git

Was ist das?

Unser selbst-gehostetes Git-Hosting, basierend auf Forgejo — einem non-profit Community-Fork von Gitea, gesteuert von Codeberg e.V. Hier leben Code, Infrastructure-as-Code (wie dieses Repo!), Dokumentation und alle künftigen internen Tools.

Schnelles Setup auf neuem Host

# Vorausgesetzt: Traefik mit Let's Encrypt läuft bereits, DNS ist gesetzt,
# Authentik OIDC-Provider ist konfiguriert (Client-ID + Secret bereit)

cp .env.example .env
# Secrets generieren
sed -i '' -e "s|<openssl rand -hex 32>|$(openssl rand -hex 32)|g" .env   # macOS
# ODER: sed -i -e "s|...|...|g" .env   auf Linux
# SMTP + OIDC Credentials manuell eintragen

docker compose up -d
sleep 30

# Admin-Fallback anlegen
docker exec -u git forgejo forgejo admin user create \
  --username admin-local \
  --email admin-local@sdda.eu \
  --password "<strong-password>" \
  --admin --must-change-password=false

# OIDC einrichten
docker exec -u git forgejo forgejo admin auth add-oauth \
  --name authentik \
  --provider openidConnect \
  --key "<CLIENT_ID>" \
  --secret "<CLIENT_SECRET>" \
  --auto-discover-url "https://welcome.sdda.eu/application/o/forgejo/.well-known/openid-configuration" \
  --scopes "openid profile email" \
  --skip-local-2fa

# admin-local sperren (Notfall-Reserve)
docker exec forgejo-db psql -U forgejo -d forgejo \
  -c "UPDATE \"user\" SET prohibit_login = true WHERE lower_name = 'admin-local';"

Zugang

  • Normal (empfohlen): Via Authentik OIDC. code.sdda.eu/user/login → "Anmelden mit authentik" — oder direkt aus dem Authentik-Dashboard (Silent SSO).
  • Voraussetzung: Mitglied der Authentik-Gruppe forgejo-users
  • Emergency-Fallback: admin-local User (in Runbook, nicht hier)

Files in diesem Ordner

  • docker-compose.yml — Stack-Definition
  • .env.example — Template, niemals echte .env committen
  • backup.sh — Nightly-Backup-Script (pg_dump + tar)
  • Agent.md — AI-Briefing für Sessions an diesem Stack
  • README.md — diese Datei

Live vs. Repo

Dieses Repo ist die versionierte Wahrheit des Stacks. Wenn du auf ai-apps eine Änderung machst (z.B. docker-compose.yml anpasst), bitte auch hier einchecken. Andernfalls driftet das Repo vom Server weg und verliert seinen Wert.

OpenProject

  • M7.1 — Forgejo Deployment mit Authentik SSO (abgeschlossen)
  • M7.2 — Repo initialisiert (dieser Commit)