[英]What is the recommended solution for user secrets storage in ASP.NET core in non-Azure production environment?
I am working on a .net core project, which needs to read some user secrets. 我正在开发一个.net核心项目,它需要读取一些用户机密。 I read the following two articles.
我读了以下两篇文章。
I am wondering if there is a similar solution for a non-Azure production environment, eg one that would work in AWS. 我想知道是否有非Azure生产环境的类似解决方案,例如可以在AWS中使用的解决方案。
.NET Core allows you to store your secrets in various places of the configuration system. .NET Core允许您将秘密存储在配置系统的各个位置。
There are many different configuration providers listed in the documentation : 文档中列出了许多不同的配置提供程序:
It's convenient to manage the user secret with Microsoft.Extensions.SecretManager.Tools on the command line and then use Microsoft.Extensions.Configuration.UserSecrets to get the secrets from your app's configuration. 在命令行上使用Microsoft.Extensions.SecretManager.Tools管理用户密钥很方便,然后使用Microsoft.Extensions.Configuration.UserSecrets从应用程序的配置中获取机密。
However, you should encrypt the stored information yourself, wherever you store it, eg. 但是,您应该自己加密存储的信息,无论您在何处存储它,例如。 the appsettings.production.json.
appsettings.production.json。
To do so you can make use of a custom configuration provider to encrypt and decrypt your secrets. 为此,您可以使用自定义配置提供程序来加密和解密您的机密。 Your custom provider should inherit from the ConfigurationProvider class as shown here .
您的自定义供应商应该从ConfigurationProvider类继承如图所示这里 。
public class CustomConfigProvider : ConfigurationProvider
{
public CustomConfigProvider() { }
public override void Load()
{
Data = MyEncryptUtils.DecryptConfiguration();
}
}
See also: Encrypted Configuration in ASP.NET Core 另请参阅: ASP.NET Core中的加密配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.