diff --git a/src/IdentityServer/Configuration/DependencyInjection/ConfigureOpenIdConnectOptions.cs b/src/IdentityServer/Configuration/DependencyInjection/ConfigureOpenIdConnectOptions.cs index b2e09a2be..12128a072 100644 --- a/src/IdentityServer/Configuration/DependencyInjection/ConfigureOpenIdConnectOptions.cs +++ b/src/IdentityServer/Configuration/DependencyInjection/ConfigureOpenIdConnectOptions.cs @@ -34,16 +34,19 @@ public void PostConfigure(string name, OpenIdConnectOptions options) options.StateDataFormat = new DistributedCacheStateDataFormatter(_serviceProvider, name); } - var distributedCacheService = _serviceProvider.GetRequiredService(); - - if (distributedCacheService is MemoryDistributedCache && !warnedInMemory) + if (!warnedInMemory) { - var logger = _serviceProvider - .GetRequiredService>(); + var distributedCacheService = _serviceProvider.GetRequiredService(); + + if (distributedCacheService is MemoryDistributedCache) + { + var logger = _serviceProvider + .GetRequiredService>(); - logger.LogInformation("You have enabled the OidcStateDataFormatterCache but the distributed cache registered is the default memory based implementation. This will store any OIDC state in memory on the server that initiated the request. If the response is processed on another server it will fail. If you are running in production, you want to switch to a real distributed cache that is shared between all nodes."); + logger.LogInformation("You have enabled the OidcStateDataFormatterCache but the distributed cache registered is the default memory based implementation. This will store any OIDC state in memory on the server that initiated the request. If the response is processed on another server it will fail. If you are running in production, you want to switch to a real distributed cache that is shared between all nodes."); - warnedInMemory = true; + warnedInMemory = true; + } } } } \ No newline at end of file