Class OidcDiscoveryCache

java.lang.Object
dev.getelements.elements.service.auth.oidc.OidcDiscoveryCache

@Singleton public class OidcDiscoveryCache extends Object
A purely in-memory, TTL-based cache of OIDC discovery documents, keyed by discovery URL. Refreshes automatically once an entry goes stale, requiring no admin action to pick up a provider's endpoint changes — the same automatic-refresh spirit as the existing JWKS cache-on-miss behavior in OidcAuthServiceOperations, but simpler: discovery documents are lightweight and only a handful of providers will ever be configured, so there is no need to persist the cache to MongoDB.

Must remain a singleton — the cache map is instance state, and each provider config re-triggers a live HTTP fetch if this class is accidentally bound with a non-singleton scope.

  • Constructor Details

    • OidcDiscoveryCache

      public OidcDiscoveryCache()
  • Method Details

    • resolve

      public OidcDiscoveryDocument resolve(String discoveryUrl)
      Returns the discovery document for the given URL, serving from cache if it was fetched within the last getRefreshIntervalSeconds() seconds, otherwise fetching fresh and caching the result.
      Parameters:
      discoveryUrl - the OIDC discovery document URL
      Returns:
      the discovery document
    • getClient

      public jakarta.ws.rs.client.Client getClient()
    • setClient

      @Inject public void setClient(jakarta.ws.rs.client.Client client)
    • getRefreshIntervalSeconds

      public long getRefreshIntervalSeconds()
    • setRefreshIntervalSeconds

      @Inject public void setRefreshIntervalSeconds(@Named("dev.getelements.elements.oidc.discovery.refresh.seconds") long refreshIntervalSeconds)