test(auth): cover userinfo SSRF scheme guard; note empty-scope caveat

Address claude-review round 7 nits on #919:
- Add test_validate_via_userinfo_rejects_non_http_scheme — a non-http(s)
  userinfo_uri is refused before any request (covers the SSRF scheme guard).
- Docstring caution on _validate_via_userinfo: userinfo-validated tokens carry
  empty scopes, so management endpoints must not gate on scopes for this path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-17 20:34:31 +02:00
co-authored by Claude Opus 4.8
parent bc6595b139
commit a53e6e7721
2 changed files with 17 additions and 0 deletions
@@ -640,6 +640,11 @@ class UnifiedTokenVerifier(TokenVerifier):
management-API allowlist is relaxed for it (authorization is still
enforced per-user by every management endpoint).
Caution: userinfo-validated tokens carry **empty scopes**. Callers must
not gate management endpoints on scopes for this path (e.g. a future
``@require_scopes``) or they would silently reject valid cross-client
tokens; the per-user ``sub`` check is the authorization gate.
Security note — bounded staleness: userinfo carries no token ``exp``, so
a validated token is cached for ``userinfo_cache_ttl`` (5 min) rather
than the 1-hour default. A revoked/expired opaque token may therefore be