在 Azure 应用程序中保护连接字符串和应用程序设置 - 如何在本地使用它们
Securing connection strings and app settings in an Azure App - how to use them locally
在作为 Azure 应用服务托管的网络应用程序中,我的 web.config
中有以下内容用于测试:
<connectionStrings>
<add name="ProductionConnection" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:something.database.windows.net,1433;Initial Catalog=DatabaseName;User Id=admin@sssdddr;Password=Pass@word1;Trusted_Connection=False;Encrypt=True;Connection Timeout=30; MultipleActiveResultSets=True" />
</connectionStrings>
我在这里尝试遵循一些基本的安全最佳实践,因此我将我的连接字符串移到了我的网络应用程序的 Application Settings
部分:
这个特定设置是一个不好的例子,因为理想情况下我只会将 ProductionConnection
存储在 Azure 中并且从不在本地使用 - 但对于其他连接字符串和 appSettings
在本地和生产中使用应该保护的,在本地开发时应该如何处理这些值?
I mean the connection string value / app setting should not be baked
into the application's bin directory
连接字符串通常位于 web.config 文件中。 web.config 永远不会在 bin 文件夹中;我们通常将它放在应用程序的根文件夹中。
我相信你的意思是存储敏感信息,如用户名和密码以访问 SQL 服务器。您不能向正在调试应用程序的开发人员隐藏连接字符串和设置。
在公司环境中,我们(开发人员)使用Windows身份验证访问 SQL 服务器。
如果您希望从开发人员那里保护 secrets/connection 字符串,请选择 Azure Key Vault,它旨在保护您的所有秘密,不让所有人知道。每个秘密都将作为 URI 公开给最终开发人员以通过 REST 使用。
为此,您需要 register your application 使用 Azure AD,因为 KeyVault 会请求 AD 令牌来提供机密。
在作为 Azure 应用服务托管的网络应用程序中,我的 web.config
中有以下内容用于测试:
<connectionStrings>
<add name="ProductionConnection" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:something.database.windows.net,1433;Initial Catalog=DatabaseName;User Id=admin@sssdddr;Password=Pass@word1;Trusted_Connection=False;Encrypt=True;Connection Timeout=30; MultipleActiveResultSets=True" />
</connectionStrings>
我在这里尝试遵循一些基本的安全最佳实践,因此我将我的连接字符串移到了我的网络应用程序的 Application Settings
部分:
这个特定设置是一个不好的例子,因为理想情况下我只会将 ProductionConnection
存储在 Azure 中并且从不在本地使用 - 但对于其他连接字符串和 appSettings
在本地和生产中使用应该保护的,在本地开发时应该如何处理这些值?
I mean the connection string value / app setting should not be baked into the application's bin directory
连接字符串通常位于 web.config 文件中。 web.config 永远不会在 bin 文件夹中;我们通常将它放在应用程序的根文件夹中。
我相信你的意思是存储敏感信息,如用户名和密码以访问 SQL 服务器。您不能向正在调试应用程序的开发人员隐藏连接字符串和设置。
在公司环境中,我们(开发人员)使用Windows身份验证访问 SQL 服务器。
如果您希望从开发人员那里保护 secrets/connection 字符串,请选择 Azure Key Vault,它旨在保护您的所有秘密,不让所有人知道。每个秘密都将作为 URI 公开给最终开发人员以通过 REST 使用。
为此,您需要 register your application 使用 Azure AD,因为 KeyVault 会请求 AD 令牌来提供机密。