gpt4 book ai didi

asp.net - 困惑于在 Azure 部署的 Web.config 中存储密码的正确过程是什么

转载 作者:行者123 更新时间:2023-12-04 12:40:13 25 4
gpt4 key购买 nike

在 Azure 上放置 MVC 5 应用程序时,我有过一次非常令人沮丧的经历。我一直在阅读以下页面:http://www.asp.net/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure

但是我还没有想到的是以下内容:

Security Warning: Do not add your secrets .config file to your project or check it into source control. By default, Visual Studio sets the Build Action to Content, which means the file is deployed. For more information see Why don't all of the files in my project folder get deployed? Although you can use any extension for the secrets .config file, it's best to keep it .config, as config files are not served by IIS. Notice also that the AppSettingsSecrets.config file is two directory levels up from the web.config file, so it's completely out of the solution directory. By moving the file out of the solution directory, "git add *" won't add it to your repository.

还有:

Security Warning: Unlike the AppSettingsSecrets.config file, the external connection strings file must be in the same directory as the root web.config file, so you'll have to take precautions to ensure you don't check it into your source repository.

问题如下:当我上传带有外部文件但未包含的 Web.config 文件时,我会收到“系统找不到指定的文件”的消息,因此为了让它消失,我必须包含 .config这些文件违背了微软发帖的目的。

我真的真的真的不明白。我已在 Azure 门户中添加了 connectionStrings 和 appSetting 的 key 。将我的密码和 secret 放在网上的正确且安全的方式是什么?我缺少什么?是因为我在 Debug模式下运行吗?

据此: How can I secure passwords stored inside web.config?

访问 Web.config 文件无需担心...

但这恰恰违背了微软的立场。

谢谢。

最佳答案

我发现以下技术是实现此目的的最简单方法。

我没有将这些设置的部署放入web.config中,而是将测试值保留在那里。然后,我通过 Azure 门户将部署值放入 Azure 网站的“应用程序设置”部分:

enter image description here

当网站运行时,这些设置将优先于 web.config 中的设置。这帮助我避免了外部化文件,使我能够保持团队可以共享的健全的开发配置,并使部署变得非常容易。

关于asp.net - 困惑于在 Azure 部署的 Web.config 中存储密码的正确过程是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33111353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com