Files
authser/docker-compose.yml
Serreau Jovann 832be361c7 Switch admin to jovann@e-cosplay.fr + disable default admin
- Rename the bootstrap human admin from jovann@siteconseil.fr to
  jovann@e-cosplay.fr in docker-compose env vars and in the realm
  import JSON. Keycloak identifies users by username so a new user
  is created on the next sync run; the old jovann@siteconseil.fr
  is left in place and can be deleted manually from the admin UI.
- Introduce a service account client `sync-bot` in the master
  realm (confidential, service accounts enabled, direct grants off)
  granted the `admin` realm role. sync.sh now authenticates via
  client_credentials, falling back to the bootstrap admin only on
  the very first run — so reconciliation keeps working after the
  default admin is disabled.
- Add disable_default_admin() at the end of the sync script. It
  first verifies that sync-bot can authenticate, then flips the
  `admin` user's `enabled` flag to false. Idempotent and safe:
  refuses to run if sync-bot auth is broken, and is a no-op if
  admin is already disabled.
- SYNC_BOT_CLIENT / SYNC_BOT_SECRET env vars added to the init
  container for both bootstrap authentication and service client
  secret reconciliation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 16:15:46 +02:00

91 lines
2.7 KiB
YAML

services:
postgres:
image: postgres:16-alpine
container_name: ecosplay-auth-db
restart: unless-stopped
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: keycloak
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- keycloak-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keycloak"]
interval: 10s
timeout: 5s
retries: 5
keycloak:
image: quay.io/keycloak/keycloak:26.0
container_name: ecosplay-auth-keycloak
restart: unless-stopped
command: ["start", "--import-realm"]
environment:
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: keycloak
KC_HOSTNAME: https://auth.e-cosplay.fr
KC_HTTP_ENABLED: "true"
KC_PROXY_HEADERS: xforwarded
KC_HEALTH_ENABLED: "true"
KC_METRICS_ENABLED: "true"
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
ports:
- "127.0.0.1:9450:8080"
volumes:
- ./themes/ecosplay:/opt/keycloak/themes/ecosplay:ro
- ./realms:/opt/keycloak/data/import:ro
healthcheck:
test: ["CMD-SHELL", "exec 3<>/dev/tcp/localhost/9000 && printf 'GET /health/ready HTTP/1.0\\r\\nHost: localhost\\r\\n\\r\\n' >&3 && grep -q UP <&3"]
interval: 10s
timeout: 5s
retries: 30
start_period: 120s
depends_on:
postgres:
condition: service_healthy
networks:
- keycloak-net
keycloak-init:
image: quay.io/keycloak/keycloak:26.0
container_name: ecosplay-auth-init
depends_on:
keycloak:
condition: service_healthy
environment:
KC_SERVER: http://keycloak:8080
KC_ADMIN: admin
KC_ADMIN_PASSWORD: admin
SMTP_HOST: email-smtp.eu-west-3.amazonaws.com
SMTP_PORT: "587"
SMTP_FROM: auth@e-cosplay.fr
SMTP_FROM_DISPLAY_NAME: E-Cosplay
SMTP_USER: AKIAWTT2T22CWBRBBDYN
SMTP_PASSWORD: BBdgb6KxRQ8mNcpWFJsZCJxbSGNdgLhKFiITMErfBlQP
LOGIN_THEME: ecosplay
ECOSPLAY_GROUPS: "gp_asso gp_contest gp_mail gp_mailling gp_member gp_ndd gp_sign gp_ticket super_admin_asso superadmin"
ADMIN_USER_USERNAME: jovann@e-cosplay.fr
ADMIN_USER_PASSWORD: Shoko1997@
ADMIN_USER_FIRSTNAME: Jovann
ADMIN_USER_LASTNAME: Serreau
SYNC_BOT_CLIENT: sync-bot
SYNC_BOT_SECRET: dev-sync-bot-9f3b2a7c1e8d4f6a0b5c2e1d7f8a4b3c
volumes:
- ./init/sync.sh:/opt/init/sync.sh:ro
entrypoint: ["/bin/bash", "/opt/init/sync.sh"]
networks:
- keycloak-net
restart: "no"
volumes:
postgres_data:
networks:
keycloak-net:
driver: bridge