当前位置: 首页 > 知识库问答 >
问题:

使用集成安全性获取Azure Key Vault秘密

那宏大
2023-03-14

我看到的关于获取访问令牌以访问Azure密钥库的所有示例都涉及到使用ClientId和ClientSecret为众所周知的https://Vault.Azure.NET资源请求一个令牌。

这工作很好...但我希望能够使用集成安全获得一个访问令牌,以访问密钥库。

例如,我有

const string VaultResource = "https://vault.azure.net";
var context = new AuthenticationContext(myTenantAuthority, false);

// using integrated auth
var token1 = await context.AcquireTokenAsync(VaultResource, nativeAppClientId, new UserCredential());

// OR interactive
var token2 = context.AcquireToken(VaultResource, nativeAppClientId, new Uri("https://localhost"), 
     PromptBehavior.Auto, new UserIdentifier(UserPrincipal.Current.UserPrincipalName, UserIdentifierType.RequiredDisplayableId));
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException occurred
  ErrorCode=invalid_grant
  HResult=-2146233088
  Message=AADSTS65001: The user or administrator has not consented to use the application with ID '306d0ff4-0f32-4c38-bdb9-4ea500000000'. Send an interactive authorization request for this user and resource.
Trace ID: 2ca2fb3f-3931-4868-b176-700f29158a3a
Correlation ID: 39875bc5-cb1c-4a62-925d-7448d8716f30
Timestamp: 2016-02-23 08:51:45Z
  Source=Microsoft.IdentityModel.Clients.ActiveDirectory
  StatusCode=400
  StackTrace:
       at Microsoft.IdentityModel.Clients.ActiveDirectory.HttpHelper.<SendPostRequestAndDeserializeJsonResponseAsync>d__0`1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<SendHttpMessageAsync>d__15.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException occurred
  ErrorCode=access_denied
  HResult=-2146233088
  Message=AADSTS65005: The client application has requested access to resource 'https://vault.azure.net'. This request has failed because the client has not specified this resource in its requiredResourceAccess list.
Trace ID: 5652658c-54bf-4880-bcc8-dea822a4b10b
Correlation ID: 1f97c7c0-858f-4542-9936-4a5114a93cc0
Timestamp: 2016-02-23 08:36:17Z
  Source=Microsoft.IdentityModel.Clients.ActiveDirectory
  StatusCode=0
  StackTrace:
       at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.RunAsyncTask[T](Task`1 task)

如何更新RequiredResourceAccessList?

更新:下面是如何配置应用程序的

共有1个答案

魏凯捷
2023-03-14

您可能需要设置委派的权限。请参阅https://azure.microsoft.com/en-gb/documentation/articles/active-directory-integration-applications/

此外,您可能需要考虑使用证书进行身份验证。查看更安全的使用密钥库的方法

 类似资料:
  • 我们有一个Spring应用程序,使用Gradle构建,使用Spring Boot 1.2.5运行。释放。我们编写了一些初始集成测试,使用Rest-Assured对Restendpoint进行测试。这起到了作用,我们的应用程序的RESTendpoint通过浏览器和Postman进行了适当的响应。 然后我们使用Spring Security实现了一个OncePerRequest estFilter和我

  • 在DownloadPayloadExtractor中,我希望获得 这些是原木的

  • 我需要阅读Azure active directory中的用户列表。客户已经创建了一个Graph API应用程序,但他们不想共享应用程序的客户机密,而是要求我们使用密钥库。如何从节点访问。js应用程序检索用户列表的密钥是什么? 我尝试了下面的一个,但给出了错误,我不知道如何验证。

  • 我在使用Spring Security的前/后授权注释和与Keycloak集成的Servlet API时遇到了问题。我调查了很多文章、教程和以下问题,但没有进一步的运气: 使用KeyClope在servlet应用程序中获取用户角色 Spring Boot Key斗篷-如何获得分配给用户的角色列表 将Spring Security注释与KeyClope一起使用 Spring Boot Spring

  • 我需要通过在连接字符串中指定用户名和密码,使用Windows身份验证用户连接到SQL Server。 不知何故,我需要建立这样的联系才能工作: 由于这个要求看起来很奇怪,我试着解释我的场景: > 在我的应用程序中,用户被映射到SQL Server用户(使用SQL身份验证或windows身份验证) 有一个Windows客户端可以从LAN内部访问数据库 我正在编写一个web应用程序(Tomcat8 s