Skip to content

PLAN: Authentik SSO Setup

╔══════════════════════════════════════════════════════════════════════╗
║ ║
║ █████╗ ██╗ ██╗████████╗██╗ ██╗███████╗███╗ ██╗████████╗ ║
║ ██╔══██╗██║ ██║╚══██╔══╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ║
║ ███████║██║ ██║ ██║ ███████║█████╗ ██╔██╗ ██║ ██║ ║
║ ██╔══██║██║ ██║ ██║ ██╔══██║██╔══╝ ██║╚██╗██║ ██║ ║
║ ██║ ██║╚██████╔╝ ██║ ██║ ██║███████╗██║ ╚████║ ██║ ║
║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ║
║ ║
║ S S O I M P L E M E N T A T I E P L A N ║
║ ║
║ Magic e-VERSE Identity & Access Management ║
║ Authentik as Centralized SSO Provider ║
║ ║
║ Status: SHELVED (Reference only) ║
║ ║
╚══════════════════════════════════════════════════════════════════════╝

Het Magic e-VERSE ecosysteem bevat tientallen services (admin panels, portal, PIM, NextCloud, N8N, monitoring, etc.) die momenteel elk hun eigen authenticatie hebben. Dit plan beschrijft de implementatie van Authentik als gecentraliseerde SSO identity provider, waarmee alle interne services via één login toegankelijk worden.


  • Eén login voor alle Magic e-VERSE interne services
  • Centraal gebruikersbeheer (onboarding/offboarding in één plek)
  • 2FA/MFA afdwingen voor alle admin-toegang
  • Role-Based Access Control (RBAC) per service en per tenant
  • Audit logging van alle login-activiteiten
  • Forward Auth / Proxy Auth voor services die geen native SSO ondersteunen

┌──────────────────────────────┐
│ Nginx Reverse Proxy │
│ (Port 80/443) │
└──────────────┬─────────────────┘
┌──────────────▼─────────────────┐
│ Authentik │
│ auth.magiceverse.online │
│ │
│ ┌───────────┐ ┌────────────┐ │
│ │ Server │ │ Worker │ │
│ │ :9000 │ │ (async) │ │
│ └───────────┘ └────────────┘ │
│ ┌───────────┐ ┌────────────┐ │
│ │ PostgreSQL│ │ Redis │ │
│ │ :5432 │ │ :6379 │ │
│ └───────────┘ └────────────┘ │
└──────────────┬─────────────────┘
┌────────────────────────┼────────────────────────┐
│ │ │
┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐
│ OAuth2/OIDC │ │ Forward Auth │ │ SAML/LDAP │
│ (Native) │ │ (Proxy) │ │ (Legacy) │
│ │ │ │ │ │
│ - NextCloud │ │ - Admin │ │ - Toekomst │
│ - N8N │ │ Panels │ │ │
│ - Grafana │ │ - Glances │ │ │
│ - Portal │ │ - DevDocs │ │ │
│ │ │ - Monitoring │ │ │
└──────────────┘ └──────────────┘ └──────────────┘

Authentik draait als Docker stack naast de bestaande containers.

Locatie: /mnt/data/magic_omniverse/magic_authentik/

docker-compose.yml
services:
authentik-postgresql:
image: docker.io/library/postgres:16-alpine
container_name: authentik_postgres
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
start_period: 20s
interval: 30s
retries: 5
timeout: 5s
volumes:
- authentik_database:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${PG_PASS:?database password required}
POSTGRES_USER: ${PG_USER:-authentik}
POSTGRES_DB: ${PG_DB:-authentik}
authentik-redis:
image: docker.io/library/redis:alpine
container_name: authentik_redis
command: --save 60 1 --loglevel warning
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
start_period: 20s
interval: 30s
retries: 5
timeout: 3s
volumes:
- authentik_redis:/data
authentik-server:
image: ghcr.io/goauthentik/server:2026.2.1
container_name: authentik_server
restart: unless-stopped
command: server
environment:
AUTHENTIK_REDIS__HOST: authentik-redis
AUTHENTIK_POSTGRESQL__HOST: authentik-postgresql
AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}
volumes:
- ./media:/media
- ./custom-templates:/templates
ports:
- "9000:9000" # HTTP
- "9443:9443" # HTTPS
depends_on:
authentik-postgresql:
condition: service_healthy
authentik-redis:
condition: service_healthy
authentik-worker:
image: ghcr.io/goauthentik/server:2026.2.1
container_name: authentik_worker
restart: unless-stopped
command: worker
environment:
AUTHENTIK_REDIS__HOST: authentik-redis
AUTHENTIK_POSTGRESQL__HOST: authentik-postgresql
AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}
user: root
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./media:/media
- ./certs:/certs
- ./custom-templates:/templates
depends_on:
authentik-postgresql:
condition: service_healthy
authentik-redis:
condition: service_healthy
volumes:
authentik_database:
driver: local
authentik_redis:
driver: local
.env
PG_PASS=<generate-secure-password>
PG_USER=authentik
PG_DB=authentik
AUTHENTIK_SECRET_KEY=<generate-with: openssl rand 60 | base64>
# AUTHENTIK_ERROR_REPORTING__ENABLED=true # Optioneel

Bestand: /etc/nginx/sites-enabled/auth.magiceverse.online

server {
listen 443 ssl http2;
server_name auth.magiceverse.online;
ssl_certificate /etc/letsencrypt/live/auth.magiceverse.online/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/auth.magiceverse.online/privkey.pem;
location / {
proxy_pass http://localhost:9000;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80;
server_name auth.magiceverse.online;
return 301 https://$host$request_uri;
}
auth.magiceverse.online → A record naar server IP
Terminal window
sudo certbot certonly --nginx -d auth.magiceverse.online

GroepBeschrijvingToegang
adminsSysteembeheerders (Wayne, Michiel)Alle services
developersOntwikkelaarsAdmin panels, DevDocs, N8N, Portal
tenant-managersTenant beheerdersSpecifieke tenant admin panels
viewersAlleen-lezen toegangPortal, DevDocs

Authentik ondersteunt meerdere bronnen:

  • Lokale gebruikers (handmatig aangemaakt)
  • Invitations (email-gebaseerde uitnodigingen)
  • Eventueel later: LDAP/AD koppeling
  1. Ga naar Flows & StagesStages → maak een Authenticator Validation Stage
  2. Configureer TOTP (Google Authenticator/Authy) als primaire methode
  3. Optioneel: WebAuthn (hardware keys) als tweede optie
  4. Voeg de MFA stage toe aan de default-authentication-flow
  5. Stel een enrollment policy in die MFA verplicht voor de admins en developers groepen

3.1 Services met Native OAuth2/OIDC Support

Section titled “3.1 Services met Native OAuth2/OIDC Support”

Deze services ondersteunen OAuth2/OIDC out-of-the-box en worden direct gekoppeld aan Authentik.

  1. In Authentik: maak een OAuth2/OpenID Provider aan
    • Client ID: nextcloud
    • Redirect URI: https://docs.magiceverse.online/apps/sociallogin/custom_oidc/authentik
    • Scopes: openid profile email
  2. In Authentik: maak een Application aan gekoppeld aan deze provider
  3. In NextCloud: installeer de Social Login app
  4. Configureer een Custom OpenID Connect provider:
    • Discover URL: https://auth.magiceverse.online/application/o/nextcloud/.well-known/openid-configuration
    • Client ID / Secret van Authentik

N8N Workflow (n8n.magiceverse.online, n8n2, n8n3)

Section titled “N8N Workflow (n8n.magiceverse.online, n8n2, n8n3)”
  1. In Authentik: maak een OAuth2/OpenID Provider per N8N instance (of gedeeld)
    • Redirect URIs: https://n8n.magiceverse.online/rest/oauth2-credential/callback
  2. In N8N environment variables toevoegen:
    Terminal window
    N8N_AUTH_TYPE=oidc
    N8N_OIDC_CLIENT_ID=n8n
    N8N_OIDC_CLIENT_SECRET=<secret>
    N8N_OIDC_ISSUER=https://auth.magiceverse.online/application/o/n8n/
  3. N8N containers herstarten
  1. In Authentik: maak een OAuth2/OpenID Provider aan voor de Portal
  2. In de Portal Vite+React app: integreer een OAuth2/OIDC client library
  3. Login flow aanpassen:
    • “Login met Magic e-VERSE SSO” knop toevoegen
    • Token validatie via Authentik’s JWKS endpoint
    • Bestaande device-auth kan naast SSO blijven draaien (migratie periode)

Services zonder native SSO-support worden beschermd via Authentik’s Forward Auth (nginx auth_request).

Browser → Nginx → auth_request naar Authentik → Authentik controleert sessie
├── Sessie geldig → Nginx proxy_pass naar service
└── Geen sessie → Redirect naar Authentik login
  1. In Authentik: maak een Proxy Provider aan (Forward Auth mode)
    • External host: de URL van de te beschermen service
    • Kies Forward auth (single application) mode
  2. Maak een Application aan gekoppeld aan deze proxy provider
  3. Configureer de Outpost (Embedded Outpost gebruiken voor eenvoud)

Maak een herbruikbaar Nginx snippet:

Bestand: /etc/nginx/snippets/authentik-auth.conf

# Authentik Forward Auth
location /outpost.goauthentik.io {
internal;
proxy_pass http://localhost:9000/outpost.goauthentik.io;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Redirect to login on 401
location @goauthentik_proxy_signin {
internal;
add_header Set-Cookie $auth_cookie;
return 302 /outpost.goauthentik.io/start?rd=$request_uri;
}

Belangrijk: In de location / block gebruik je auth_request /outpost.goauthentik.io/auth/nginx; (met /auth/nginx suffix).

Voorbeeld voor Glances (glances.magiceverse.online):

server {
listen 443 ssl http2;
server_name glances.magiceverse.online;
ssl_certificate /etc/letsencrypt/live/glances.magiceverse.online/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/glances.magiceverse.online/privkey.pem;
include /etc/nginx/snippets/authentik-auth.conf;
location / {
auth_request /outpost.goauthentik.io/auth/nginx;
auth_request_set $auth_cookie $upstream_http_set_cookie;
error_page 401 = @goauthentik_proxy_signin;
# Headers met user info van Authentik
auth_request_set $authentik_username $upstream_http_x_authentik_username;
auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
auth_request_set $authentik_email $upstream_http_x_authentik_email;
proxy_set_header X-authentik-username $authentik_username;
proxy_set_header X-authentik-groups $authentik_groups;
proxy_set_header X-authentik-email $authentik_email;
proxy_pass http://localhost:<service-port>;
}
}
ServiceDomeinHuidige AuthPrioriteit
Glancesglances.magiceverse.onlineGeen/BasicHoog
DevDocsdevdocs.magiceverse.onlineGeenMedium
Escalationescalation.magiceverse.onlineOnbekendMedium
Contactscontacts.magiceverse.onlineOnbekendMedium
AI Checkaicheck.magiceverse.onlineOnbekendMedium
Crypto Monitorcrypto.magiceverse.onlineOnbekendLaag
ServiceDomeinHuidige AuthPrioriteit
NextClouddocs.magiceverse.onlineEigen loginHoog
N8N (3x)n8n*.magiceverse.onlineIP whitelistHoog
Portalportal.magiceverse.onlineDevice authMedium
ServiceDomeinAanpak
Admin Developmentadmin-development.magiceverse.onlineForward Auth of Medusa auth plugin
Admin Brinxxadmin-brinxx.magiceverse.onlineForward Auth of Medusa auth plugin
Admin Defaultadmin-default.magiceverse.onlineForward Auth of Medusa auth plugin
… (8 tenants)admin-*.magiceverse.onlineZelfde aanpak voor alle tenants

admins → Alle services
developers → Alle admin panels + dev tools
├── tenant-brinxx → admin-brinxx + brinxx storefront
├── tenant-logohorloge → admin-logohorloge + logohorloge storefront
├── tenant-bovisales → admin-bovisales + bovisales storefront
├── tenant-desluis → admin-desluis + desluis storefront
├── tenant-jodasign → admin-jodasign + jodasign storefront
├── tenant-demo → admin-demo + demo storefront
└── tenant-default → admin-default + default storefront

Per Application in Authentik een Group Membership Policy instellen:

Application: admin-brinxx
→ Policy: Gebruiker moet lid zijn van "admins" OF "developers" OF "tenant-brinxx"
Application: n8n
→ Policy: Gebruiker moet lid zijn van "admins" OF "developers"
Application: glances
→ Policy: Gebruiker moet lid zijn van "admins"

Fase 5: Migratie & Uitfasering Bestaande Auth

Section titled “Fase 5: Migratie & Uitfasering Bestaande Auth”
  1. Week 1-2: Authentik deployen + basisconfiguratie (Fase 1 & 2)
  2. Week 2-3: Forward Auth inrichten voor eenvoudige services (Glances, DevDocs, etc.)
  3. Week 3-4: OAuth2/OIDC koppelen voor NextCloud en N8N
  4. Week 4-5: Forward Auth voor Medusa admin panels (dubbele auth-laag)
  5. Week 5-6: Portal SSO integratie
  6. Week 6+: IP whitelists en device-auth geleidelijk uitfaseren waar SSO overneemt

5.2 Bestaande Auth Behouden (Overgangsperiode)

Section titled “5.2 Bestaande Auth Behouden (Overgangsperiode)”

Tijdens de migratie blijven bestaande authenticatiemethoden werken:

Huidige MethodeServiceStatus na SSO
Device AuthPortalBlijft naast SSO (later uitfaseren)
IP WhitelistN8N instancesVerwijderen na SSO + MFA
Basic AuthGlancesVerwijderen na Forward Auth
Medusa JWTAdmin panelsBlijft (Forward Auth als extra laag)
NextCloud loginNextCloudOptioneel behouden naast OIDC

Terminal window
# PostgreSQL backup
docker exec authentik_postgres pg_dump -U authentik authentik > /tmp/authentik_backup_$(date +%Y%m%d).sql
# Media & templates backup
tar -czf /tmp/authentik_media_$(date +%Y%m%d).tar.gz /mnt/data/magic_omniverse/magic_authentik/media/
  • Authentik heeft een ingebouwd Admin Dashboard met login statistieken
  • Events log toont alle authenticatie-events, policy decisions, en admin acties
  • Koppel eventueel aan bestaande monitoring (Glances/Grafana)
Terminal window
# Check of Authentik draait
curl -s https://auth.magiceverse.online/-/health/ready/

Terminal window
# 1. Directory aanmaken
mkdir -p /mnt/data/magic_omniverse/magic_authentik
cd /mnt/data/magic_omniverse/magic_authentik
# 2. Secret key genereren
echo "AUTHENTIK_SECRET_KEY=$(openssl rand 60 | base64)" >> .env
echo "PG_PASS=$(openssl rand 36 | base64)" >> .env
echo "PG_USER=authentik" >> .env
echo "PG_DB=authentik" >> .env
# 3. Docker compose starten
docker compose up -d
# 4. SSL certificaat
sudo certbot certonly --nginx -d auth.magiceverse.online
# 5. Nginx config activeren
sudo ln -s /etc/nginx/sites-available/auth.magiceverse.online /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Terminal window
# Logs bekijken
docker logs authentik_server --tail=50 -f
# Herstarten
cd /mnt/data/magic_omniverse/magic_authentik
docker compose restart
# Updaten
docker compose pull
docker compose up -d

  • DNS record auth.magiceverse.online aanmaken
  • Directory /mnt/data/magic_omniverse/magic_authentik/ opzetten
  • Docker Compose + .env configureren
  • Authentik 2026.2.1 starten + initial setup wizard doorlopen
  • SSL certificaat via Let’s Encrypt (verloopt 2026-06-08)
  • Nginx reverse proxy configureren
  • Gebruikersgroepen aanmaken (admins, developers, tenant-managers, viewers + 7 tenant groepen)
  • MFA/TOTP in authentication flow
  • Forward Auth snippet aanmaken (/etc/nginx/snippets/authentik-auth.conf)
  • Forward Auth inrichten voor Glances
  • Forward Auth inrichten voor DevDocs
  • Forward Auth inrichten voor Escalation
  • Forward Auth inrichten voor Contacts
  • Forward Auth inrichten voor AI Check
  • Forward Auth inrichten voor Crypto Monitor
  • 14 Proxy Providers + Applications aangemaakt
  • RBAC policies gebonden (admins, developers, tenant-specifiek)
  • OAuth2/OIDC koppeling NextCloud
  • OAuth2/OIDC koppeling N8N (3 instances)
  • Forward Auth voor Medusa admin panels (Nginx config aanpassing nodig)
  • Portal SSO integratie
  • Bestaande IP whitelists/device-auth evalueren en uitfaseren
  • Backup strategie implementeren
  • Team documenteren en trainen