Reputation: 1
I have implemented code to store Azure AD tokens in an InMemoryCache for validation. As a result, when accessing any [Authorized] endpoint, the validation process should occur using the tokens stored in the InMemoryCache, bypassing the need for additional Azure AD API calls.
builder.Services.AddAuthentication()
.AddMicrosoftIdentityWebApi(configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi()
.AddInMemoryTokenCaches(options =>
{
options.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(Convert.ToDouble(configuration["AzureAuthCacheInMinute"]));
});
Upvotes: 0
Views: 83