azure - 使用 DataProtectionProvider 连接到 Azure Key Vault
问题描述
我花了很多时间配置 .Net Core 的 DataProtectionProvider 以将密钥存储在 Azure Key Vault 中。问题是我似乎无法创建正确的 Blob URI,或者至少我认为这是问题所在,因为其他一切似乎都井然有序,但我仍然未经授权。
在 Azure 中,我注册了一个应用程序和客户端密码,创建了一个保管库和一个密钥,以及一个几乎为应用程序提供所有权限的访问策略。
这是我的 ConfigureServices 的相关部分:
string uri = "https://{vault-name}.vault.azure.net/keys/{vault-name}/{key}" + "se=2020-01-01&sp=r&spr=https&sv=2018-11-09&sr=b&sig={sig}";
string keyIdentifier = "https://{vault-name}.vault.azure.net/keys/{vault-name}";
string clientId = "{application-id";
string clientSecret = "{client-secret}";
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddDataProtection()
.PersistKeysToAzureBlobStorage(new Uri(uri)) // requires Microsoft.AspNetCore.DataProtection.AzureStorage
.ProtectKeysWithAzureKeyVault(keyIdentifier, clientId, clientSecret); //requires Microsoft.AspNetCore.DataProtection.AzureKeyVault
services.AddControllers();
我对如何生成 sas 很感兴趣。该文档似乎暗示这与存储帐户有关,但我看不到任何将存储帐户与密钥保管库相关联的明显方法。因此,我从 Azure CLI 尝试了一些不同的方法,但似乎没有任何东西可以通过我过去的身份验证。
任何帮助将非常感激。
解决方案
It looks like you are trying to pass the uri for Key Vault to .PeristKeysToAzureBlobStorage()
. Instead you need to pass the uri for the blob in storage that is going to hold the key ring. This is noted in the doc for the Azure Storage provider.
You can generate the SAS link through the portal as pictured or you can utilize the CLI to create the link.
推荐阅读
- html - 如何限制angularjs输入字段的长度
- laravel - 如何对具有不同模型的两个合并集合进行排序
- c# - 正则表达式强制和可选组
- postgresql - 提取具有多个条件的字符串 - sql
- reactjs - 创建 URL 以从 react (SIP) 启动 Skype
- google-apps-script - 由于 Google+ 登录功能已被弃用,我是否需要更改我的 Apps 脚本代码?
- angularjs - 有没有办法用#mdDialog Service 触发 mat-dialog 组件?
- python - 生成多个带有臀部列表的菜单项
- c - 如果我将字符串传递给函数,如何复制字符串中的内容?
- java - 尝试为 Spring Boot App 的黄瓜集成测试加载不同的属性?