Skip to content

Commit

Permalink
Perform checks in smarter order
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersAbel committed May 22, 2024
1 parent 1c4255a commit 47728c4
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ public void PostConfigure(string name, OpenIdConnectOptions options)
options.StateDataFormat = new DistributedCacheStateDataFormatter(_serviceProvider, name);
}

var distributedCacheService = _serviceProvider.GetRequiredService<IDistributedCache>();

if (distributedCacheService is MemoryDistributedCache && !warnedInMemory)
if (!warnedInMemory)
{
var logger = _serviceProvider
.GetRequiredService<ILogger<ConfigureOpenIdConnectOptions>>();
var distributedCacheService = _serviceProvider.GetRequiredService<IDistributedCache>();

if (distributedCacheService is MemoryDistributedCache)
{
var logger = _serviceProvider
.GetRequiredService<ILogger<ConfigureOpenIdConnectOptions>>();

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;
}
}
}
}

0 comments on commit 47728c4

Please sign in to comment.