Commit Graph
2 Commits
Author SHA1 Message Date
rockandpoimen e20e3f7be3 feat(audit): log successful JWT auth with subject, acting_party, roles (#21)
CI / CI (push) Successful in 3m39s
Add audit trail for authenticated API requests.

## Changes
- Add `auth ok` info log after JWT validation passes
- Export `ClaimString`/`ClaimStringSlice` from identity package
- Log fields: subject, acting_party, roles/permissions, path, method

## Log format
```json
{"level":"info","message":"auth ok","extra":{"subject":"2213aa...","acting_party":"portfolio-agent","roles":"llm:inference,memory:read","path":"/v1/chat/completions","method":"POST"}}
```

## Why
Gateway only logged auth failures — no audit trail for who accessed LLM endpoints. Required for cluster access auditing.

Complements existing X-Forwarded-User header injection (already complete).

---------

Co-authored-by: poimen <[email protected]>
Reviewed-on: #21
2026-09-09 22:38:01 +00:00
rockandpoimen 6f7b850193 feat(identity): inject X-Forwarded-User headers after JWT validation (#15)
CI / CI (push) Successful in 3m14s
Closes homelab#9 (P3.4)

## Changes

- New `internal/identity` package: header injection + anti-spoofing
- `proxy.go`: strip spoofed headers on all requests, inject identity after JWT validation

## Headers

| Header | Source | When |
|--------|--------|------|
| X-Forwarded-User | sub claim | Always after JWT |
| X-Forwarded-Roles | roles or permissions claim | Always after JWT |
| X-Acting-Service | azp claim | Only when azp != sub |
| X-Auth-Verified | literal "true" | Always after JWT |

## Tests

13 tests, 93.9% coverage. Covers: spoofing, service accounts, human users, empty claims, nil values, wildcard, mixed types, precedence.

---------

Co-authored-by: Poimen <[email protected]>
Reviewed-on: #15
2026-09-08 23:08:39 +00:00