Authentik logoIdentity Provider

Authentik

Identity provider và SSO tự host, hỗ trợ SAML, OAuth2, LDAP và nhiều giao thức xác thực.

Ghi chú review

Cần PostgreSQL và Redis. Cấu hình phức tạp hơn các app đơn giản nhưng rất mạnh cho quản lý danh tính tập trung.

Hướng dẫn deploy

Chạy bằng Docker Compose với PostgreSQL và Redis. Cần cấu hình domain và secret key đúng.

  1. Tạo file .env với secret key, domain và cấu hình email.
  2. Chạy Docker Compose với Authentik server, worker, PostgreSQL và Redis.
  3. Truy cập web UI tại port 9000, thiết lập mật khẩu admin.
  4. Cấu hình providers (OAuth2, SAML, LDAP) cho từng ứng dụng.
  5. Tạo flows và policies để quản lý xác thực và uỷ quyền.
Backup:Backup database PostgreSQL và thư mục media. Redis chỉ lưu cache nên không bắt buộc backup.

Copy để chạy trên server

Dùng từng block riêng: lưu compose trước, hoặc copy script bash để tạo file và chạy container.

docker-compose.ymlyaml
services:
  authentik-server:
    image: ghcr.io/goauthentik/server:latest
    container_name: authentik_server
    command: server
    environment:
      AUTHENTIK_SECRET_KEY: "change-me-to-a-long-random-string" # CHANGE THIS
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgres
      AUTHENTIK_POSTGRESQL__USER: authentik
      AUTHENTIK_POSTGRESQL__PASSWORD: CHANGEME_db_password # CHANGE THIS
      AUTHENTIK_POSTGRESQL__NAME: authentik
    ports:
      - "9000:9000"
    depends_on:
      - postgres
      - redis
    restart: unless-stopped

  authentik-worker:
    image: ghcr.io/goauthentik/server:latest
    container_name: authentik_worker
    command: worker
    environment:
      AUTHENTIK_SECRET_KEY: "change-me-to-a-long-random-string" # CHANGE THIS
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgres
      AUTHENTIK_POSTGRESQL__USER: authentik
      AUTHENTIK_POSTGRESQL__PASSWORD: CHANGEME_db_password # CHANGE THIS
      AUTHENTIK_POSTGRESQL__NAME: authentik
    depends_on:
      - postgres
      - redis
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    container_name: authentik_postgres
    environment:
      POSTGRES_USER: authentik
      POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
      POSTGRES_DB: authentik
    volumes:
      - ./postgres:/var/lib/postgresql/data
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: authentik_redis
    restart: unless-stopped
setup.shbash
#!/usr/bin/env bash
set -euo pipefail

sudo mkdir -p /opt/authentik
sudo chown "$USER":"$USER" /opt/authentik
cd /opt/authentik

cat > docker-compose.yml <<'COMPOSE'
services:
  authentik-server:
    image: ghcr.io/goauthentik/server:latest
    container_name: authentik_server
    command: server
    environment:
      AUTHENTIK_SECRET_KEY: "change-me-to-a-long-random-string" # CHANGE THIS
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgres
      AUTHENTIK_POSTGRESQL__USER: authentik
      AUTHENTIK_POSTGRESQL__PASSWORD: CHANGEME_db_password # CHANGE THIS
      AUTHENTIK_POSTGRESQL__NAME: authentik
    ports:
      - "9000:9000"
    depends_on:
      - postgres
      - redis
    restart: unless-stopped

  authentik-worker:
    image: ghcr.io/goauthentik/server:latest
    container_name: authentik_worker
    command: worker
    environment:
      AUTHENTIK_SECRET_KEY: "change-me-to-a-long-random-string" # CHANGE THIS
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgres
      AUTHENTIK_POSTGRESQL__USER: authentik
      AUTHENTIK_POSTGRESQL__PASSWORD: CHANGEME_db_password # CHANGE THIS
      AUTHENTIK_POSTGRESQL__NAME: authentik
    depends_on:
      - postgres
      - redis
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    container_name: authentik_postgres
    environment:
      POSTGRES_USER: authentik
      POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
      POSTGRES_DB: authentik
    volumes:
      - ./postgres:/var/lib/postgresql/data
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: authentik_redis
    restart: unless-stopped
COMPOSE

docker compose up -d
echo "Authentik is running on http://SERVER_IP:9000"

Stack

PythonTypeScriptPostgreSQLRedis