Phase 26 F1: mount fail-closed Keycloak JWT authz on Go microservices - #74
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Change
auth_guard.goin each service mounts the validator on all routes except/health,/healthz,/ready,/readyz,/livez,/metrics,/admin/metrics.KEYCLOAK_JWKS_URL/KEYCLOAK_URL/KEYCLOAK_ISSUER→ protected routes return503 {"error":"auth not configured"}; probes never bricked.AUTH_MODE=edgeescape hatch (explicit opt-in only): trusts APISIX edge-injectedX-User/X-User-ID/X-Consumer-Username, else 401. Default mode always validates the JWT (exp/iss/aud, RS256 vs realm JWKS).PUT /parties|/quotes|/transfers/*+/error) andGET /dfsp/jwks.json— Hub interop authenticated by FSPIOP JWS, not Keycloak./api/payments/*now JWT-gated./api/ledger/*+ gRPC interceptor — verified, unchanged.Verification
go build ./...exit 0 for all 17 touched services, clean module cache, go1.25.4 (GOPROXY=goproxy.cn, GOTOOLCHAIN=local). No go.mod/go.sum changes (validator is stdlib-only).