Skip to content

signing key rollover

Jean-Marc Prieur edited this page Oct 29, 2024 · 2 revisions

Algorithm

The algorithm for the signing key rollover is:

The ConfigurationManager<T> class in the AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet repository manages the retrieval of configuration data, including keys from the OIDC endpoint, in a resilient way. Here's a summary of the algorithm used:

  1. Initialization The constructor initializes the ConfigurationManager with a metadata address, a configuration retriever, a document retriever, and optional configuration validator and cache options.
  2. Fetching Configuration The GetConfigurationAsync method is the entry point for retrieving the configuration. It first checks if the current configuration is up-to-date based on the AutomaticRefreshInterval. If the configuration is null or outdated, it attempts to fetch the configuration from the metadata endpoint.
  3. Synchronization and Singleton Pattern A semaphore (_configurationNullLock) ensures that only one thread fetches the configuration when it is null. The _configurationRetrieverState ensures that only one task updates the configuration at a time using Interlocked.CompareExchange.
  4. Configuration Retrieval If the configuration is null, it locks the semaphore and fetches the configuration using the IConfigurationRetriever's GetConfigurationAsync method. If successful, it updates the configuration and validates it using the optional IConfigurationValidator.
  5. Error Handling Errors during configuration retrieval are logged, and if the configuration is still null, an exception is thrown. The UpdateCurrentConfiguration method is called asynchronously to update the configuration if needed.
  6. Automatic Refresh The RequestRefresh method triggers an update if the refresh interval has passed since the last request.

The algorithm ensures resilience by: = Using synchronization mechanisms (semaphore and atomic operations) to prevent race conditions.

  • Implementing automatic refresh intervals and on-demand refresh requests.
  • Validating the configuration before updating it.
  • Logging errors and handling exceptions gracefully.

Clone this wiki locally