Tired of managing separate logins for every self-hosted service? Authentik is an open-source identity provider that brings enterprise-grade SSO, MFA, and user management to your homelab — all running on your own infrastructure.
Why Self-Host an Identity Provider?
If you're running more than a handful of self-hosted services, you've probably felt the pain: separate usernames and passwords for Grafana, Portainer, Nextcloud, and everything else. Password managers help, but they don't solve the real problem — centralized identity and access control.
Authentik gives you:
- Single Sign-On (SSO) — One login for all your services
- Multi-Factor Authentication (MFA) — TOTP, WebAuthn, Duo support
- LDAP & OAuth2/OIDC — Compatible with virtually everything
- Granular policies — Control who can access what, when, and from where
- Self-service portal — Users manage their own MFA devices and passwords
Prerequisites
- A VPS or server with Docker and Docker Compose installed
- Minimum 2GB RAM (4GB recommended for production)
- A domain name pointed to your server
- Traefik or another reverse proxy handling TLS (recommended)
Step 1: Create the Docker Compose File
Create a directory for Authentik and set up the compose file:
mkdir -p ~/authentik && cd ~/authentik
mkdir -p data/custom-templates data/media data/certs
# docker-compose.yml
version: '3.8'
services:
postgresql:
image: docker.io/library/postgres:16-alpine
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
start_period: 20s
interval: 30s
timeout: 10s
retries: 5
volumes:
- database:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${PG_PASS:?database password required}
POSTGRES_USER: ${PG_USER:-authentik}
POSTGRES_DB: ${PG_DB:-authentik}
env_file:
- .env
redis:
image: docker.io/library/redis:alpine
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
start_period: 20s
interval: 30s
timeout: 10s
retries: 5
volumes:
- redis:/data
server:
image: ghcr.io/goauthentik/server:2024.10
restart: unless-stopped
command: server
environment:
AUTHENTIK_REDIS__HOST: redis
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}
AUTHENTIK_ERROR_REPORTING__ENABLED: "true"
volumes:
- ./data/custom-templates:/templates
- ./data/media:/media
- ./data/certs:/certs
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- "9000:9000"
- "9443:9443"
depends_on:
postgresql:
condition: service_healthy
redis:
condition: service_healthy
worker:
image: ghcr.io/goauthentik/server:2024.10
restart: unless-stopped
command: worker
environment:
AUTHENTIK_REDIS__HOST: redis
AUTHENTIK_POSTGRESQL__HOST: 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:
- ./data/custom-templates:/templates
- ./data/media:/media
- ./data/certs:/certs
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
postgresql:
condition: service_healthy
redis:
condition: service_healthy
volumes:
database:
redis:
Step 2: Configure Environment Variables
Generate a secure secret key and create your .env file:
# Generate a random secret key
openssl rand -base64 36 > .secret_key
# Create .env file
cat > .env << 'EOF'
PG_USER=authentik
PG_DB=authentik
PG_PASS=$(openssl rand -base64 36)
AUTHENTIK_SECRET_KEY=$(cat .secret_key)
AUTHENTIK_BOOTSTRAP_PASSWORD=adminpassword123
AUTHENTIK_BOOTSTRAP_TOKEN=admintoken123
EOF
Important: Change the bootstrap password and token to something secure. These are only used for the initial setup.
Step 3: Start Authentik
docker compose up -d
Wait about 30 seconds for the database migrations to complete, then access the web interface at http://your-server-ip:9000.
Step 4: Initial Setup
- Log in with username
akadminand your bootstrap password - Go to Admin Interface → System → Settings
- Update the domain to your actual domain (e.g.,
auth.yourdomain.com) - Navigate to Identity & Access → Applications → Providers
- Create a new provider for each service you want to protect
Step 5: Protect a Service (Example: Grafana)
Let's set up SSO for Grafana using OAuth2:
- In Authentik, go to Applications → Providers → Create
- Choose OAuth2/OpenID Provider
- Set the redirect URI to
https://grafana.yourdomain.com/login/generic_oauth - Note the Client ID and Client Secret
- Create an Application and link it to this provider
In Grafana's configuration:
[auth.generic_oauth]
enabled = true
name = Authentik
allow_sign_up = true
client_id = YOUR_CLIENT_ID
client_secret = YOUR_CLIENT_SECRET
scopes = openid profile email
auth_url = https://auth.yourdomain.com/application/o/authorize/
token_url = https://auth.yourdomain.com/application/o/token/
api_url = https://auth.yourdomain.com/application/o/userinfo/
Restart Grafana — you'll now see a "Sign in with Authentik" button.
Verification
- Visit
https://auth.yourdomain.com— you should see the Authentik login page - Create a test user and log in
- Access a protected service — it should redirect to Authentik for authentication
- Check that MFA can be enabled in the user settings
Next Steps
- Enable MFA — Require TOTP or WebAuthn for all users
- Set up LDAP — For services that don't support OAuth2
- Configure policies — Restrict access by group, time, or network
- Add more providers — Protect Portainer, Nextcloud, MinIO, and everything else
- Set up email — Configure SMTP for password recovery and notifications
Related Guides
- Self-Host Keycloak: Enterprise SSO for Your Homelab — Alternative identity provider
- Self-Host Traefik: The Ultimate Reverse Proxy — TLS termination for Authentik
- Self-Host Portainer — Manage your Docker stack
With Authentik running, you've got centralized identity management that rivals commercial solutions like Okta and Auth0 — fully under your control, with no per-user pricing.