-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Encryption strategy for Distributed token cache #1044
Comments
One possibility: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/introduction Configuration: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-5.0 for instance: // In startup.cs / or when adding cache
services.AddDataProtection()
.PersistKeysToAzureBlobStorage(dataProtectionConnectionString, dataProtectionContainerName, dataProtectionKeyFile)
.ProtectKeysWithAzureKeyVault(new Uri(dataProtectionKeyKeyUri), cred)
.SetApplicationName(AuthenticationConstants.ApplicationName);
// In the controller etc ...
var dataProtectionProvider = serviceProvider.GetService<IDataProtectionProvider> |
Proposed experience.ASP.NET CoreASP.NET Core developers who want to benefit from cache encryption will add a few lines in their startup.cs: services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi()
.AddMicrosoftGraph(Configuration.GetSection("GraphBeta"))
.AddDownstreamWebApi("GraphBeta", Configuration.GetSection("GraphBeta"))
.AddDistributedTokenCache();
services.AddDistributedMemoryCache();
services.Configure<MsalDistributedTokenCacheAdapterOptions>(o =>
{
o.Encrypt = true;
});
}); It's also possible to control the data protector: services.AddDataProtection()
.PersistKeysToAzureBlobStorage(
dataProtectionConnectionString,
dataProtectionContainerName,
dataProtectionKeyFile)
.ProtectKeysWithAzureKeyVault(new Uri(dataProtectionKeyKeyUri), cred)
.SetApplicationName(AuthenticationConstants.ApplicationName); ASP.NET classic or .NET or .NET Core clientapp = ConfidentialClientApplicationBuilder.Create(AuthenticationConfig.ClientId)
.WithClientSecret(AuthenticationConfig.ClientSecret)
.WithRedirectUri(AuthenticationConfig.RedirectUri)
.WithAuthority(new Uri(AuthenticationConfig.Authority))
.Build();
clientapp.AddDistributedTokenCache(services =>
{
services.AddDistributedMemoryCache();
services.Configure<MsalDistributedTokenCacheAdapterOptions>(o =>
{
o.Encrypt = true;
});
}); Proposed design:
Questions
|
Included in 1.15 release |
Is your feature request related to a problem? Please describe.
Today the distributed token cache does not encrypt the blob for caches.
Describe the solution you'd like
Provide an optional way to enable apps developer to provide/choose an encryption strategy
The text was updated successfully, but these errors were encountered: