Skip to content

Phase 26 F1: mount fail-closed Keycloak JWT authz on Go microservices - #76

Merged
munisp merged 1 commit into
mainfrom
phase26/f1-authz
Oct 3, 2026
Merged

munisp merged 1 commit into
mainfrom
phase26/f1-authz

Conversation

@munisp

@munisp munisp commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Problem (G4 CRITICAL)

Go microservices shipped Keycloak RS256/JWKS validators (internal/middleware/keycloak_validator.go) that were dead code — never mounted. Every HTTP route accepted unauthenticated requests, including notification-dispatcher's admin POST endpoints.

(Supersedes empty squash #74, which raced a concurrent merge and landed no diff.)

Change

  • New auth_guard.go in each service mounts the validator on all routes except /health, /healthz, /ready, /readyz, /livez, /metrics, /admin/metrics.
  • Validator copies added where missing: notification-dispatcher, payment-service, temporal-query-service, mojaloop-gateway.
  • Fail-closed: no KEYCLOAK_JWKS_URL/KEYCLOAK_URL/KEYCLOAK_ISSUER → protected routes return 503 {"error":"auth not configured"}; probes never bricked.
  • AUTH_MODE=edge escape hatch (explicit opt-in only): trusts APISIX edge-injected X-User/X-User-ID/X-Consumer-Username, else 401. Default mode always validates the JWT (RS256 vs realm JWKS, exp/iss/aud).
  • mojaloop-gateway documented public routes: FSPIOP callbacks (PUT /parties|/quotes|/transfers/* + /error) and GET /dfsp/jwks.json — Hub interop authenticated by FSPIOP JWS, not Keycloak. /api/payments/* now JWT-gated.
  • tigerbeetle-bridge: already enforced PRA-012 auth on /api/ledger/* + gRPC interceptor — verified, unchanged.
  • workflow-service untouched. drizzle/* and server/** untouched. No route paths or response shapes changed.

Verification

go build ./... exit 0 for all 17 services, clean module cache, go1.25.4 (GOPROXY=goproxy.cn, GOTOOLCHAIN=local). No go.mod/go.sum changes (validator is stdlib-only).

The per-service Keycloak RS256/JWKS validators were dead code — never
mounted — so every route accepted unauthenticated requests. This mounts them:

- New auth_guard.go per service wrapping the router on ALL routes except
  /health, /healthz, /ready, /readyz, /livez, /metrics, /admin/metrics.
- Validator copies added where missing (notification-dispatcher,
  payment-service, temporal-query-service, mojaloop-gateway).
- notification-dispatcher admin POST endpoints (/admin/refresh-tokens,
  /admin/force-refresh) now require a valid token; /healthz and
  /admin/metrics stay open.
- mojaloop-gateway: FSPIOP callback endpoints (PUT /parties|quotes|transfers/*
  and /error variants) and GET /dfsp/jwks.json are documented intentional
  public routes — the Mojaloop Hub authenticates via FSPIOP JWS signatures,
  not Keycloak. /api/payments/* is now JWT-gated.
- FAIL-CLOSED: with no KEYCLOAK_JWKS_URL/KEYCLOAK_URL/KEYCLOAK_ISSUER,
  protected routes return 503 {"error":"auth not configured"}; probes stay open.
- AUTH_MODE=edge escape hatch (explicit opt-in only): trusts APISIX
  edge-injected X-User/X-User-ID/X-Consumer-Username headers, 401 without.
  Default mode validates the JWT.
- tigerbeetle-bridge already enforced PRA-012 auth on /api/ledger/* and gRPC;
  left unchanged.
- workflow-service untouched (owned separately). No route paths or response
  shapes changed. go build ./... passes for all 17 services (go1.25.4).
@munisp
munisp merged commit 549640e into main Oct 3, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant