feat: JWT auth validation with Authentik OIDC

- Add jwt_validator module with JWKS caching (TTL + refresh-on-miss)
- Implement RS256 algorithm pinning + claim validation
- Replace apikey with Bearer token validation in http_server
- Add capability-based access control (memory:read/write/*)
- Backward compatible: MEM_AUTH_MODE=jwt|apikey (default: apikey)
- 16 tests passing (7 unit + 9 integration)
- Docs: JWT_AUTH.md with deployment guide

Config via env vars:
- MEM_AUTH_MODE=jwt
- AUTHENTIK_ISSUER=https://authentik.riotpiao.com/application/o/poimen-memory/
- AUTHENTIK_AUDIENCE=poimen-memory
- JWT_CACHE_TTL_SECS=3600 (optional)

Gw passes Authorization: Bearer <token> header
Memory validates + checks permissions claim
This commit is contained in:
Story Crater Bot
2026-08-27 12:29:23 -07:00
parent 82cc2c8310
commit 47e55afae3
9 changed files with 997 additions and 45 deletions
+1
View File
@@ -41,6 +41,7 @@ uuid = { version = "1.6", features = ["v4", "serde"] }
sqlx = { version = "0.7", features = ["postgres", "runtime-tokio-rustls", "chrono", "uuid", "json"] }
pgvector = { version = "0.2", features = ["sqlx"] }
base64 = "0.21"
jsonwebtoken = "9.2"
[dev-dependencies]
toml = { workspace = true }