azure - 多个azure应用程序如何使用相同的jwt token 进行身份验证

标签 azure authentication azure-active-directory jwt single-sign-on

我们有两个 RestAPI,托管在 azure Kubernetes 中。这些 API 使用 Azure 应用程序通过 SSO 对用户进行身份验证。我们计划从一个 api(连接到其自己的应用程序)获取 token ,并在另一个 API(连接到另一个应用程序)中使用它。有办法实现这个目标吗?目前,api1 中生成的 token 在 api2 中无效,反之亦然。对于 API,我们使用此配置。希望我的问题很清楚,如果需要进一步说明,请告诉我。

用户模拟和范围(更多详细信息为 here )

我们正在使用access_token和oath2 This与我的非常相似,但我们不打算访问 Azure 资源,因此不确定这个问题的答案是否仍然适用于我们的问题。

我遇到了this但不确定这是否是最好的解决方案,甚至是一个解决方案。

需要澄清的是,所有 Azure 应用程序和 API 都位于一个租户中。

最佳答案

I agree with @Jack Jiang, you can make use of On-Behalf-of flow to achieve your scenario.

我为示例 webapi1 webapi2 webapi3 创建了三个 Azure AD 应用程序。

webapi1 中,我添加了以下 Api 权限:

enter image description here

webapi2 中,我添加了以下 Api 权限:

enter image description here

我通过 Postman 使用以下参数为 webapi1 生成了访问 token :

https://login.microsoftonline.com/TenantID/oauth2/v2.0/token

client_id:webapi1ClientId
scope:api://webapi2ID/webapi2.read
grant_type:authorization_code
redirect_uri:https://jwt.ms
code:code
client_secret:ClientSecret

enter image description here

使用上面生成的访问 token ,我尝试调用 webapi3 Api,如下所示:

https://login.microsoftonline.com/TenantID/oauth2/v2.0/token

client_id:webapi2ClientID
client_secret:ClientSecret
grant_type:urn:ietf:params:oauth:grant-type:jwt-bearer
assertion:access_token_generatedabove
requested_token_use:on_behalf_of
scope:api://webapi3ID/webapi3.read

enter image description here

否则,您可以使用 Client Credential flow调用 API。

引用:

Microsoft identity platform and OAuth2.0 On-Behalf-Of flow - Microsoft Entra

关于azure - 多个azure应用程序如何使用相同的jwt token 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76808038/

相关文章:

c# - 如果我快速连续运行多个 Azure 搜索索引器,是否有办法访问 Azure SDK 中的等待索引器队列?

javascript - 我可以以编程方式从 Power BI Embedded 报表导出筛选的数据吗?

authentication - 使用 Google OAuth2 进行非交互式授权

c# - 获取每个应用程序的所有用户 Azure Active Directory .NET Web Api C#

Azure存储通过nodejs添加角色分配AD组

ruby - 在 Azure AD 中通过 Graph API 创建应用程序时获取 'Service_InternalServerError'

postgresql - Azure PostgreSQL - 如何创建管理员用户

powershell - 使用 ARM 输出或 powershell 获取 Azure Function 默认 key 的方法

c# - 如何以编程方式登录到窗口 7,8 桌面

javascript - 使用 AngularJS 拦截器防止 HTTP 基本身份验证对话框