【问题标题】:Access KeyVault with Subject Name + Issuer Auth使用主题名称 + 颁发者身份验证访问 KeyVault
【发布时间】:2021-03-02 06:26:07
【问题描述】:

我正在将我的 AAD 应用程序切换到 Subject Name + Issuer auth 并且我相信我已经正确地做到了,因为我可以通过我的测试应用程序获得一个令牌,但我不明白如何使用 SN+I连接到 KeyVault。 Azure.Security.KeyVault.Secrets.SecretClient 的构造函数采用 TokenCredential,但没有一个派生类似乎与 SN+I auth 明显相关。我不确定如何处理这种情况。任何提示将不胜感激!

【问题讨论】:

    标签: adal azure-keyvault


    【解决方案1】:

    您可能想要使用ClientCertificateCredentialOptions.SendCertificateChain = true 构造的ClientCertificateCredential。它will include x5c header in client claims when acquiring a token to enable subject name / issuer based authentication for the ClientCertificateCredential.

    【讨论】:

      【解决方案2】:

      我通过创建我自己的从 TokenCredential 继承的“SniTokenCredential”类来实现这个场景。它检索这样的令牌:

      IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(_applicationId)
          .WithAuthority($"https://login.microsoftonline.com/{_tenantId}")
          .WithCertificate(_certificate)
          .Build();
      AuthenticationResult authResult = await app.AcquireTokenForClient(requestContext.Scopes)
          .WithSendX5C(true)
          .ExecuteAsync(cancellationToken);
      

      然后我可以像这样返回一个 AccessToken:

      return new AccessToken(authResult.AccessToken, authResult.ExpiresOn);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-11-04
        • 1970-01-01
        • 2017-10-01
        • 2013-07-28
        • 2018-07-07
        • 2018-07-19
        • 2018-05-02
        相关资源
        最近更新 更多