From 64af78a984491d365577cea0a86110a459b881af Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Wed, 11 Feb 2026 18:32:55 +0100 Subject: [PATCH] feat: integrate mintel gatekeeper into testing environment --- .gitea/workflows/deploy.yml | 13 +++++++++++-- docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index f2d93644..c33adc5e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -266,8 +266,17 @@ jobs: ENV_FILE=$ENV_FILE EOF - # AUTH_MIDDLEWARE logic - printf "AUTH_MIDDLEWARE=%s\n" "$( [[ "$TARGET" == "production" ]] && echo "${PROJECT_NAME}-compress" || echo "${PROJECT_NAME}-auth,${PROJECT_NAME}-compress" )" >> .env.deploy + # Middleware Selection Logic + # Regular app routes get auth on non-production + # Unprotected routes (/stats, /errors) never get auth + STD_MW="${PROJECT_NAME}-ratelimit,${PROJECT_NAME}-forward,${PROJECT_NAME}-compress" + + if [[ "$TARGET" == "production" ]]; then + printf "AUTH_MIDDLEWARE=%s\n" "$STD_MW" >> .env.deploy + else + printf "AUTH_MIDDLEWARE=%s\n" "${PROJECT_NAME}-auth,$STD_MW" >> .env.deploy + fi + printf "AUTH_MIDDLEWARE_UNPROTECTED=%s\n" "$STD_MW" >> .env.deploy - name: 🚀 SSH Deploy shell: bash diff --git a/docker-compose.yml b/docker-compose.yml index 58b13d8a..996793a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls.certresolver=le" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls=true" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.service=${PROJECT_NAME:-klz-cables}" - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.middlewares=${TRAEFIK_MIDDLEWARES:-${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${PROJECT_NAME:-klz-cables}-compress}" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.middlewares=${AUTH_MIDDLEWARE:-${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${PROJECT_NAME:-klz-cables}-compress}" # HTTPS router (Unprotected - for Analytics & Errors) - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-unprotected.rule=${TRAEFIK_HOST_RULE:-Host(`klz-cables.com`)} && PathPrefix(`/stats`, `/errors`)" @@ -27,7 +27,7 @@ services: - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-unprotected.tls.certresolver=le" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-unprotected.tls=true" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-unprotected.service=${PROJECT_NAME:-klz-cables}" - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-unprotected.middlewares=${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${PROJECT_NAME:-klz-cables}-compress" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-unprotected.middlewares=${AUTH_MIDDLEWARE_UNPROTECTED:-${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${PROJECT_NAME:-klz-cables}-compress}" - "traefik.http.services.${PROJECT_NAME:-klz-cables}.loadbalancer.server.port=3000" - "traefik.http.services.${PROJECT_NAME:-klz-cables}.loadbalancer.server.scheme=http" @@ -40,6 +40,11 @@ services: - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-forward.headers.customrequestheaders.X-Forwarded-Proto=https" - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-forward.headers.customrequestheaders.X-Forwarded-Ssl=on" + # Authentication Middleware (ForwardAuth) + - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-auth.forwardauth.address=http://${PROJECT_NAME:-klz-cables}-gatekeeper:3000/api/verify" + - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-auth.forwardauth.trustForwardHeader=true" + - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-auth.forwardauth.authResponseHeaders=X-Auth-User" + # Middleware Definitions - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-ratelimit.ratelimit.average=100" - "traefik.http.middlewares.${PROJECT_NAME:-klz-cables}-ratelimit.ratelimit.burst=50" @@ -50,6 +55,33 @@ services: retries: 5 start_period: 30s + gatekeeper: + image: registry.infra.mintel.me/mintel/gatekeeper:v1.7.3 + restart: always + networks: + infra: + aliases: + - ${PROJECT_NAME:-klz-cables}-gatekeeper + env_file: + - ${ENV_FILE:-.env} + environment: + PORT: 3000 + PROJECT_NAME: ${PROJECT_NAME:-KLZ Cables} + PROJECT_COLOR: "#82ed20" + COOKIE_DOMAIN: ${COOKIE_DOMAIN} + AUTH_COOKIE_NAME: ${AUTH_COOKIE_NAME:-klz_gatekeeper_session} + GATEKEEPER_PASSWORD: ${GATEKEEPER_PASSWORD} + NEXT_PUBLIC_BASE_URL: https://gatekeeper.${TRAEFIK_HOST:-testing.klz-cables.com} + labels: + - "traefik.enable=true" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.rule=(Host(`${TRAEFIK_HOST:-testing.klz-cables.com}`) && PathPrefix(`/gatekeeper`)) || Host(`gatekeeper.${TRAEFIK_HOST:-testing.klz-cables.com}`)" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.entrypoints=websecure" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls.certresolver=le" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls=true" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.service=${PROJECT_NAME:-klz-cables}-gatekeeper" + - "traefik.http.services.${PROJECT_NAME:-klz-cables}-gatekeeper.loadbalancer.server.port=3000" + - "traefik.docker.network=infra" + directus: image: directus/directus:11 restart: always