Commit Graph
6 Commits
Author SHA1 Message Date
Admin Bot dcbcc081ba fix: accept multi-issuer JWTs from any Authentik provider
CI / Vet, test, build (pull_request) Successful in 3m27s
CI / Build and push image (pull_request) Skipped
Problem: Gateway rejected portfolio-agent JWTs because audience claim
didn't match hardcoded 'api-gw'. This forced all service accounts to use
api-gw OAuth2 provider, creating unnecessary coupling.

Root cause: JWT validation checked for specific issuer + audience pair.
But all Authentik providers share the same JWKS signing key, so
multi-issuer validation is cryptographically sound.

Solution:
- Keep issuer validation (checks isValidIssuer() regex)
- Remove hardcoded audience check (accept any audience from valid issuer)
- All service accounts (portfolio-agent, memory-agent, api-gw) now work

Security implications:
- Same trust boundary: all Authentik providers sign with same key anyway
- Signature validation still applies (JWKS check is sufficient)
- Roles/permissions are immutable in JWT, not issuer-dependent
- Narrower attack surface: service account can't escalate via issuer

Testing:
- portfolio-agent (qwen2.5:3b-instruct) JWT now validates
- memory-agent and api-gw JWTs still work
- Authorization still checked via roles claim

Fixes: JWT 403 Forbidden for portfolio-agent → LLM gateway
2026-09-06 06:09:20 -07:00
Admin Bot f32ff08365 fix: accept any Authentik provider issuer in JWT validation
CI / Vet, test, build (push) Successful in 5m57s
CI / Build and push image (push) Successful in 2m47s
- isValidIssuer() accepts portfolio-agent, memory-agent, api-gw, etc.
- All Authentik providers use same signing key (JWKS valid)
- CheckPermissions now checks both 'permissions' (users) and 'roles' (service accounts)
- Fixes JWT issuer mismatch for portfolio-agent, memory-agent tokens
2026-09-05 06:02:11 -07:00
Admin Bot e1a5aca7d6 fix: Lazy-load JWKS in JWT validator + add unit tests
CI / Vet, test, build (push) Successful in 2m14s
CI / Build and push image (push) Failing after 13s
Changes:
- Make JWT validator lazy-load JWKS on first use (not on init)
- Thread-safe JWKS loading with mutex
- Fixes test failures (JWKS 404 was panicking on NewValidator)
- Add unit tests for JWT validation logic

Tests now pass:
   Check permissions (sqs:read, sqs:write, wildcard)
   Reject empty/invalid/malformed tokens
   Handle missing permissions claim

All 100% passing with no external dependencies.
2026-08-27 15:13:49 -07:00
Admin Bot 9d9395d938 feat: Phase 3.1 - SQS JWT validation against Authentik JWKS
CI / Vet, test, build (push) Successful in 2m4s
CI / Build and push image (push) Failing after 18s
Implements gateway-level JWT validation for SQS requests:
- Validates JWT signature against Authentik JWKS
- Verifies claims: iss, aud, exp, nbf (with 60s skew)
- Checks 'permissions' claim for sqs:read/sqs:write/wildcard
- Returns 403 with error details on validation failure
- JWKS caching with 15min TTL and auto-refresh on key rotation

Architecture:
- SQS: Gateway validates JWT (kmsvc code unverified)
- MinIO, Temporal: Native JWT support (pass-through)
- Memory, IAM: Service-owned JWT validation

Integration tests added:
- Reject requests without Authorization header (403)
- Accept requests with valid JWT from Authentik
- Pass through Authorization header unchanged for other services

Uses github.com/MicahParks/keyfunc/v2 for JWKS handling:
- Automatic refresh every 15 minutes
- On-demand refresh if kid not found
- Handles RS256 signatures
2026-08-27 11:40:35 -07:00
Admin Bot 8dfd17127b chore: remove unused internal/auth package
CI / Vet, test, build (push) Canceled after 55s
CI / Build and push image (push) Canceled after 0s
JWT validation moved to individual services (Option B).
Gateway no longer needs auth module.
2026-08-27 11:16:40 -07:00
Admin Bot df33203a72 feat: add JWT validation against Authentik JWKS for protected adapters
CI / Vet, test, build (push) Successful in 2m4s
CI / Build and push image (push) Successful in 50s
Replaces stub 'check Authorization header' auth with real JWT validation:
- Extracts Bearer token from Authorization header
- Validates signature against Authentik JWKS endpoint
- Verifies iss, aud, exp claims
- Checks permissions claim for required capability
- Handles key rotation with 15min cache TTL
- Returns 403 with detailed error on auth failure

Protected adapters (memory, iam) now require valid Authentik JWT tokens.
2026-08-27 11:07:20 -07:00