Commit Graph
6 Commits
Author SHA1 Message Date
jarvisandClaude Sonnet 4.6 b01c9b3bb0 feat(federation): mTLS AuthGuard with OID-based grant resolution (FED-M3-03)
Adds FederationAuthGuard that validates inbound mTLS client certs on
federation API routes. Extracts custom OIDs (grantId, subjectUserId),
loads the grant+peer from DB in one query, asserts active status, and
validates cert serial as defense-in-depth. Attaches FederationContext
to requests on success and uses federation wire-format error envelopes
(not raw NestJS exceptions) for 401/403 responses.

New files:
- apps/gateway/src/federation/oid.util.ts — shared OID extraction (no dupe ASN.1 logic)
- apps/gateway/src/federation/server/federation-auth.guard.ts — guard impl
- apps/gateway/src/federation/server/federation-context.ts — FederationContext type + module augment
- apps/gateway/src/federation/server/index.ts — barrel export
- apps/gateway/src/federation/server/__tests__/federation-auth.guard.spec.ts — 11 unit tests

Modified:
- apps/gateway/src/federation/grants.service.ts — adds getGrantWithPeer() with join
- apps/gateway/src/federation/federation.module.ts — registers FederationAuthGuard as provider

Closes #462

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-25 06:33:37 -05:00
jarvisandClaude Sonnet 4.6 21650fb194 feat(federation): outbound mTLS FederationClient (FED-M3-08)
Implements FederationClientService — a NestJS injectable that dials peer
gateways over mTLS (undici Agent with cert+sealed-key from federation_peers),
invokes list/get/capabilities verbs, validates responses via Zod, and surfaces
all failure modes as typed FederationClientError with a coherent error code
taxonomy (PEER_NOT_FOUND, PEER_INACTIVE, PEER_MISCONFIGURED, NETWORK,
FORBIDDEN, HTTP_{status}, INVALID_RESPONSE).

Per-peer Agent instances are cached in a Map for the service lifetime;
flushPeer(peerId) invalidates the cache for M5/M6 cert rotation and
revocation events.

Wired into FederationModule providers + exports so QuerySourceService
(M3-09) can inject it.

13 unit tests covering all required scenarios via undici MockAgent +
real sealClientKey/unsealClientKey round-trip.

Closes #462

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-23 22:16:52 -05:00
jason.woltje 74fe60d8d6 feat(federation): admin controller + CLI federation commands (FED-M2-08) (#498) 2026-04-22 04:39:46 +00:00
jason.woltje 0bfaa56e9e feat(federation): enrollment controller + single-use token flow (FED-M2-07) (#497) 2026-04-22 04:23:19 +00:00
jason.woltje 01dd6b9fa1 feat(federation): grants service CRUD + status transitions (FED-M2-06) (#496) 2026-04-22 03:57:12 +00:00
jason.woltje 1038ae76e1 feat(federation): Step-CA client service for grant certs (FED-M2-04) (#494) 2026-04-22 03:34:37 +00:00