01Beyond Basic SSO
02Docker Compose Setup
1services: 2 authentik-server: 3 image: ghcr.io/goauthentik/server:2025.24 command: server5 environment: 6 AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}7 AUTHENTIK_REDIS__HOST: redis8 AUTHENTIK_POSTGRESQL__HOST: postgresql9 AUTHENTIK_POSTGRESQL__USER: authentik10 AUTHENTIK_POSTGRESQL__NAME: authentik11 AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}12 volumes: 13 - authentik-media:/media14 - authentik-templates:/templates15 ports: 16 - "9000:9000"17 - "9443:9443"18 depends_on: 19 postgresql: 20 condition: service_healthy21 redis: 22 condition: service_healthy23 restart: unless-stopped2425 authentik-worker: 26 image: ghcr.io/goauthentik/server:2025.227 command: worker28 environment: 29 AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}30 AUTHENTIK_REDIS__HOST: redis31 AUTHENTIK_POSTGRESQL__HOST: postgresql32 AUTHENTIK_POSTGRESQL__USER: authentik33 AUTHENTIK_POSTGRESQL__NAME: authentik34 AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}35 volumes: 36 - authentik-media:/media37 - authentik-templates:/templates38 - authentik-certs:/certs39 depends_on: 40 postgresql: 41 condition: service_healthy42 redis: 43 condition: service_healthy44 restart: unless-stopped4546 postgresql: 47 image: postgres:16-alpine48 environment: 49 POSTGRES_PASSWORD: ${PG_PASS}50 POSTGRES_USER: authentik51 POSTGRES_DB: authentik52 volumes: 53 - postgres-data:/var/lib/postgresql/data54 healthcheck: 55 test: ["CMD", "pg_isready", "-U", "authentik"]56 interval: 10s57 timeout: 5s58 retries: 559 restart: unless-stopped6061 redis: 62 image: redis:7-alpine63 command: --save 60 1 --loglevel warning64 volumes: 65 - redis-data:/data66 healthcheck: 67 test: ["CMD", "redis-cli", "ping"]68 interval: 10s69 timeout: 5s70 retries: 571 restart: unless-stopped7273volumes: 74 postgres-data: 75 redis-data: 76 authentik-media: 77 authentik-templates: 78 authentik-certs: The AUTHENTIK_SECRET_KEY must be a long, random string (at least 50 characters). Generate it with openssl rand -base64 60 and store it securely. Changing this key after initial setup invalidates all sessions and tokens, effectively locking everyone out until they re-authenticate.
03Initial Configuration and Admin Setup
1# Generate secrets:2# openssl rand -base64 60 | tr -d '\n'3AUTHENTIK_SECRET_KEY=your-very-long-random-secret-key-here45# PostgreSQL6PG_PASS=strong-database-password78# Initial admin bootstrap (optional — remove after first login)9AUTHENTIK_BOOTSTRAP_PASSWORD=initial-admin-password10AUTHENTIK_BOOTSTRAP_EMAIL=admin@example.com1112# Email (for password recovery and notifications)13AUTHENTIK_EMAIL__HOST=smtp.example.com14AUTHENTIK_EMAIL__PORT=58715AUTHENTIK_EMAIL__USE_TLS=true16AUTHENTIK_EMAIL__USERNAME=authentik@example.com17AUTHENTIK_EMAIL__PASSWORD=email-password18AUTHENTIK_EMAIL__FROM=authentik@example.comSet AUTHENTIK_BOOTSTRAP_PASSWORD to create an admin account automatically on first start. Remove this variable after initial login — it's only used when no admin account exists. This is useful for automated deployments and infrastructure-as-code setups where you can't run through the web wizard.
04Protecting Services with Proxy Provider
1# Traefik labels for forward auth with Authentik2services: 3 my-service: 4 image: myapp:latest5 labels: 6 - traefik.enable=true7 - traefik.http.routers.myapp.rule=Host(`app.example.com`)8 - traefik.http.routers.myapp.entrypoints=websecure9 - traefik.http.routers.myapp.tls.certresolver=letsencrypt10 # Forward auth to Authentik11 - traefik.http.routers.myapp.middlewares=authentik@docker12 - traefik.http.middlewares.authentik.forwardAuth.address=http://authentik-server:9000/outpost.goauthentik.io/auth/traefik13 - traefik.http.middlewares.authentik.forwardAuth.trustForwardHeader=true14 - traefik.http.middlewares.authentik.forwardAuth.authResponseHeaders=X-authentik-username,X-authentik-groups,X-authentik-email