Skip to main content

Module cimd_cache

Module cimd_cache 

Source
Expand description

Client ID Metadata Document cache.

Spec: draft-ietf-oauth-client-id-metadata-document-00 §6.2 — servers SHOULD cache metadata respecting HTTP cache headers. MCP 2025-11-25 authorization spec (§ Client ID Metadata Documents → Authorization Servers) lifts this requirement verbatim.

Design:

This cache is a thin OAuth-specific wrapper over the shared TtlCache substrate (extracted in #524). TtlCache provides the eviction machinery — per-entry TTL, lazy version-tagged deletion on re-insert, bounded inline reaping and a capacity bound (next-to-expire victim). This wrapper adds:

  • TTL clamping: HTTP Cache-Control: max-age / Expires is clamped to [min_ttl, max_ttl] (default [5min, 24h]) before the entry is inserted. Defends against thundering-herd refetch (max-age=0) and unbounded staleness.
  • RegisteredClient keying by client_id URL.

The public API remains async for call-site compatibility; the underlying TtlCache is synchronous (operations are short, in-memory and never span an .await).

Structs§

CimdCache
CIMD metadata cache. Thread-safe; cheap to share via Arc.
CimdCacheConfig
Cache configuration. Defaults documented per field.