#526 [API/Perf] JWT config fetched from Vault on EVERY request

closed critical Created 2025-12-17 15:00 · Updated 2025-12-17 15:12

Description

Edit
**File:** api/oauth_handlers/oauth2.py:115-133 **Problem:** `verify_jwt_token()` calls `get_oauth2_config()` which fetches 4 secrets from Vault on EVERY authenticated request. At 1000 req/sec = 4000 Vault reads/sec. **Fix:** Add TTL cache: ```python _JWT_CONFIG_CACHE = None _JWT_CONFIG_CACHE_TIME = 0 JWT_CONFIG_TTL = 300 # 5 minutes def get_oauth2_config() -> dict[str, Any]: global _JWT_CONFIG_CACHE, _JWT_CONFIG_CACHE_TIME now = time.time() if _JWT_CONFIG_CACHE and (now - _JWT_CONFIG_CACHE_TIME) < JWT_CONFIG_TTL: return _JWT_CONFIG_CACHE # ... fetch from Vault ... ``` **Impact:** 50-100ms saved per request (Vault latency).

Comments

Loading comments...

Context

Loading context...

Audit History

View All
Loading audit history...