即使在禁用设置后,Azure Key Vault 也会返回机密

卡斯帕兄弟

我正在为一个业余项目试验 Azure Key Vault。起初,我在本地开发,但现在我的数据库在 Azure 中。所以我希望这个连接字符串在 Key Vault 中是安全的。我设法通过 Visual Studio 中的连接服务选项来完成。连接已建立,一切都按预期工作。不过,现在我想在开发中使用 appsettings.json 中的配置值访问本地数据库。我认为通过将设置包装在 Program.cs 中的 ConfigureAppConfiguration 委托中,如下所示将绕过 Key Vault 并转到本地 appsettings。但是当运行这段代码时,我仍然得到 Key Vault 秘密值(并且在调试中跳过了代码(所以 IsDevelopment 是真的)

            if (!context.HostingEnvironment.IsDevelopment())
            {
                var builtConfig = config.Build();
                var keyVaultEndpoint = GetKeyVaultEndpoint();
                if (!string.IsNullOrEmpty(keyVaultEndpoint))
                {
                    var azureServiceTokenProvider = new AzureServiceTokenProvider();
                    var keyVaultClient = new KeyVaultClient(
                        new KeyVaultClient.AuthenticationCallback(
                            azureServiceTokenProvider.KeyVaultTokenCallback));
                    config.AddAzureKeyVault(
                        keyVaultEndpoint, keyVaultClient, new DefaultKeyVaultSecretManager());
                }
            }

所以我的问题是;

  1. 有没有其他人经历过这种奇怪的行为?
  2. 如何正确处理在本地机器上切换密钥保管库
卡斯帕兄弟

事实证明,这毕竟不是代码和密钥库。在实施 keyvault 之前,我已经尝试过用户机密,结果这仍然在我的配置提供程序中执行。当我调试时,我查看了 IConfiguration.Providers 的内容,发现我的设置存在于位于我计算机上的 secrets.json 中。

C:\Users\Username\AppData\Roaming\Microsoft\UserSecrets\e53d8827-fdcb-496d-8290-9ff7fcf0ec04

我希望其他有这个问题的人免于挖掘代码

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Azure Key Vault门户未显示机密

无法在Azure Key Vault中设置机密值

在 Azure Function 中访问 Azure Key Vault 机密

尝试使用 Azure Functions 在 Azure Key Vault 中创建机密

无法在 ansible 中获取 Azure Key Vault 机密

在Azure DevOps中动态访问Key Vault机密变量

如何在链接模板中使用 Azure Key Vault 机密

如何检查Azure Key Vault中的机密是否存在

无需 SecretVersion 即可访问 Azure Key Vault 机密

从Service Fabric访问Azure Key Vault上的机密

如何通过本地asp.net应用程序在Azure Key Vault中设置机密

Azure Key Vault Chef 食谱

如何在 Azure Devops 发布管道中读取多行 Azure Key Vault 机密

将Azure Key Vault机密分配给Devops发布管道的连接字符串

如何使用脚本批量创建和更新 Azure Key Vault 机密?

如何从Azure Key Vault机密中清除到期日期?

从 Azure Key Vault 检索机密:Task<string> 还是常规字符串?

无法使用 azure JavaScript 函数和 Key Vault 机密检索 cosmosDB 数据

如何从Configuration Builder中的Key Vault获取机密值

从 Azure Functions 动态访问 Azure Key Vault

从Azure Batch访问Azure Key Vault

有没有一种方法可以让App Services设置使用Key Vault机密?

将Key Vault设置绑定到课程

无法使用python从Azure Key Vault获取机密/证书| “ KeyVaultManagementClient”对象没有属性“ get_secret”

仅当在ARM模板中进行更改时,才如何更新Azure Key Vault中的机密或检查其是否存在

Azure Key Vault环境变量

无法从Azure Key Vault读取值

使用 Azure Key Vault 签署 JWT 令牌

Azure Key Vault 中的密钥权限