简体   繁体   English

在 web.config 中保存敏感信息

[英]Keeping sensitive information in web.config

Is it secure to store username or password in web.config as the other parameters eg timeout period in ASP.NET MVC applications?将用户名或密码存储在web.config作为其他参数(例如ASP.NET MVC应用程序中的超时时间)是否安全? If not, is it possible to make these parameters securable so that they cannot be encoded in the web.config file on the published server?如果没有,是否可以使这些参数安全,以便它们无法在已发布服务器上的web.config文件中进行编码? On the other hand, would you suggest to store username, password and the other constant parameters in a Class (*.cs) file as static values?另一方面,您是否建议将用户名、密码和其他常量参数作为静态值存储在Class (*.cs) 文件中? Could you please clarify me about which approach is better in order to store such parameters?您能否澄清一下哪种方法更好地存储这些参数?

You should never store sensitive data in source code.您永远不应该在源代码中存储敏感数据。 You can use the configSource attribute to replace the entire <connectionStrings> markup.您可以使用configSource属性来替换整个<connectionStrings>标记。

<connectionStrings configSource="ConnectionStrings.config">
</connectionStrings>

ConnectionStrings.config should be in the same folder as Web.config. ConnectionStrings.config应与 Web.config 位于同一文件夹中。 It's best to keep extension .config, as config files are not served by IIS.最好保留扩展名 .config,因为 IIS 不提供配置文件。 This file must be ignored by version control system.版本控制系统必须忽略此文件。

https://www.asp.net/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure https://www.asp.net/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure

check these links:检查这些链接:

http://www.4guysfromrolla.com/articles/021506-1.aspx http://www.4guysfromrolla.com/articles/021506-1.aspx

http://www.aspnettutorials.com/tutorials/advanced/encrypt-conn-str-asp4-cs.aspx http://www.aspnettutorials.com/tutorials/advanced/encrypt-conn-str-asp4-cs.aspx

Better yet, do not use SQL Server Security and instead use Integrated Security and only allow the account your web app (pool) runs under to access the DB.更好的是,不要使用 SQL Server 安全性,而是使用集成安全性,并且只允许您的 Web 应用程序(池)在其下运行的帐户访问数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM