- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Microsoft.Azure.keyVault
尝试从 Azure 的 key 保管库中获取 secret 。
我已将一个应用程序注册为 native API 和 Web API。
登录 AD 成功(可以通过在 AuthenticationContext.AcquireTokenAsync
上获取有效的 AccessToken
来确认这一点)。
在 Azure AD 中,两个应用程序都在 Key Vault 中获得了访问控制 (IAM) 和访问策略。我已经确认 Key Vault Base Url 和 Secret Name 是正确的,但是在进行以下调用时
var sec = kv.GetSecretAsync("https://xxxxxxx.vault.azure.net", "xxsecretnamexx").GetAwaiter().GetResult();
一直报错
{"Operation returned an invalid status code 'Unauthorized'"} Microsoft.Azure.KeyVault.Models.KeyVaultErrorException
旁注:尝试通过以用户身份登录来执行此操作。获取token的代码如下
.AcquireTokenAsync(resourceUri,clientId, new Uri(redirectUri), new PlatformParameters(PromptBehavior.SelectAccount))
我们的工作代码使用已注册的 Azure AD 应用程序的 ID 和密码,该应用程序有权访问 keystore 。
尝试在不使用关联的已注册 Azure AD 应用程序的 ID 和 secret 的情况下执行相同的操作,而是在获取 Azure AD 的访问 token 时显示登录提示。
最佳答案
我用下面的代码测试它,它在我这边工作正常。 resourceUri 是 https://vault.azure.net
static string appId = "application Id";
static string tenantId = "tenant id";
static string uri = "http://localhost:13526"; //redirect uri
static void Main(string[] args)
{
var kv = new KeyVaultClient(GetAccessToken);
var scret = kv.GetSecretAsync("https://xxxx.vault.azure.net", "xxxx").GetAwaiter().GetResult();
}
public static async Task<string> GetAccessToken(string azureTenantId,string clientId,string redirectUri)
{
var context = new AuthenticationContext("https://login.windows.net/" + tenantId);
var tokenResult = await context.AcquireTokenAsync("https://vault.azure.net", appId, new Uri(uri), new PlatformParameters(PromptBehavior.SelectAccount));
return tokenResult.AccessToken;
}
以下是我的详细步骤。
1.注册一个原生应用
2.添加KeyVault权限
3.添加上面的代码,在我这边测试。
Packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hyak.Common" version="1.0.2" targetFramework="net461" />
<package id="Microsoft.Azure.Common" version="2.0.4" targetFramework="net461" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Azure.KeyVault" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net461" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net461" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.17.0" targetFramework="net461" />
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net461" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net461" />
</packages>
关于c# - 尝试从 Azure Key Vault 获取 secret 时获得未授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46731941/
我正在尝试在我的 minikube 上启动并运行 keycloak。 我正在安装keycloak helm upgrade -i -f kubernetes/keycloak/values.yaml
我将我的数据库密码存储到AWS密钥管理器的Secret Value字段中。如果我使用以下代码,如何检索密码值?。在密钥管理器中定义的密钥:密钥在密钥管理器中定义的值:DBPwd。当我写入日志文件时,上
I am storing my database password into the Secret value field in the aws secret manager. How do I
我正在尝试在 AWS CDK 上组合一个相对简单的堆栈,其中涉及来自 aws-ecs-patterns 的 ApplicationLoadBalancedFargateService。 我的问题涉及
今天我在悠闲地阅读时偶然发现了 Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryp
不是一个真正的编程问题,但很想知道 Kubernetes 或 Minikube 如何管理 secret 并在多个节点/pod 上使用它? 假设我创建了一个 secret 来使用 kubectl 提取图
我需要从 AWS dynamoDB 和第三方 https 服务中获取元素并将这些结果合并到 AWS appSyn 中并将结果作为 graphQL 响应发回 我正在使用的第三方服务需要客户端证书。我没有
我收到一个错误: gpg: no default secret key: No secret key gpg: [stdin]: clearsign failed: No secret key GPG
我正在尝试为 kubernetes 集群设置私有(private) docker 镜像注册表。我正在关注 link $ cat ~/.docker/config.json | base64 ew
当我开发一个API服务器时,我需要给API服务器一些账户信息,这些信息不应该给任何人看。K8s对这种情况推荐secret,所以我用了。 但我想知道这个 secret 是否真的是 secret 。 se
在大多数有关在 Kubernetes 中使用 secret 的示例中,您都可以找到类似的示例: apiVersion: v1 kind: Secret metadata: name: mysecr
我正在与 terraform 合作,在 azure 中启动不同的资源。其中一些资源包含敏感数据,我希望将其安全地存储在 aws Secret Manager 中。这在 Terraform 中是可行的过
我有带有有效 key 的 Azure 应用程序注册。 我正在尝试使用 v1.0 获取 token ,如下所示(clientId 是上述应用程序注册的 ID) $body = @{ grant_
本文讨论如何安装 secret 卷。 https://learn.microsoft.com/en-us/azure/container-instances/container-instances-v
我正在使用 kubernetes 将 Rails 应用程序部署到谷歌容器引擎。 遵循 kubernetes secret 文档:http://kubernetes.io/v1.1/docs/user-
我正在与 terraform 合作,在 azure 中启动不同的资源。其中一些资源包含敏感数据,我希望将其安全地存储在 aws Secret Manager 中。这在 Terraform 中是可行的过
我有带有有效 key 的 Azure 应用程序注册。 我正在尝试使用 v1.0 获取 token ,如下所示(clientId 是上述应用程序注册的 ID) $body = @{ grant_
本文讨论如何安装 secret 卷。 https://learn.microsoft.com/en-us/azure/container-instances/container-instances-v
我有一个 python 脚本,它在 AWS 中创建一些访问 key 并将它们存储在 secret 管理器中。 但是,当我存储 key 时,我收到一条错误消息: The secret value can
我在 Secrets Manager 控制台上创建了一个 key 。然后我尝试使用 Go 代码 quickstart guide喜欢 ctx := context.Background() clien
我是一名优秀的程序员,十分优秀!