【问题标题】:Understanding Microsoft Azure AD On-Behalf-Of (OBO) flow了解 Microsoft Azure AD 代表 (OBO) 流
【发布时间】:2019-07-02 01:48:05
【问题描述】:

FE ->(token_a) Middleman ->(token_b) DownstreamServiceA

我的理解是,Middleman要对DownstreamServiceA进行API调用,需要用token_a换取token_b。我试图在邮递员中模拟这种行为。但我无法使用token_a 兑换token_b。我收到以下错误

AADSTS65001: The user or administrator has not consented to use the application with ID '{my-middleman-clientid}'

在 Azure 门户上,我已将 FE API 权限配置为可以访问 DownstreamServiceAMiddleman 的公开 API 范围。也代表我的组织用户授予管理员同意。

获取 token_a

POST to https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
grant_type:password
client_secret: foobar
client_id: my-fe-clientid
username: awesome
password: bar
scope: api://{MiddlemanId}/Middleman.All

兑换token_b

POST to https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
grant_type: urn:ietf:params:oauth:grant-type:jwt-bearer
client_id: my-middleman-clientid
client_secret: foobar
scope: api://{DownstreamServiceAId}/ServiceA.all
assertion: {token_a}
requested_token_use: on_behalf_of

我可以知道我做错了什么吗?我的理解是,我的 FE 需要预先请求并授予 DownStreamServiceA 范围的权限,这是我在 Azure 门户上通过管理员授权完成的。

【问题讨论】:

    标签: azure azure-active-directory


    【解决方案1】:

    您似乎已授予 Middleman 的 FE 访问权限,并且您已授予 DownstreamServiceA 的 FE 访问权限,但您可能未授予 Middleman 对 DownstreamServiceA 的访问权限。

    有几种方法可以做到这一点,如Granting consent for the middle-tier application 中所述:

    • 在 Middlemanm 中,将 FE 声明为“已知客户端应用程序”(清单/应用程序对象中的 knownClientApplications)并通过在 FE 处请求 scope=openid api://{MiddlemanId}/.default 来触发“组合”同意。同意提示将包含 FE 和 Middleman 所需的所有权限,并且记录的授权将根据需要正确设置为 FE 到 Middleman 和 Middleman 到 DownstreamServiceA。
    • 在 DownstreamServiceA 中,将 Middleman 声明为“预授权”应用程序(应用程序注册 > 公开 API > 授权客户端应用程序)。 FE 的同意提示将包含任何中间人到 DownstreamServiceA 的权限,这些权限将被视为已授予。
    • 在 Middleman,手动授予对所需权限的同意。如果您是租户的管理员,这有时是最简单的方法。 (例如,应用注册 > API 权限 > 授予管理员许可)

    【讨论】:

    • 没有必要明确地将 FE 访问连接到 Azure 门户上的 DownstreamServiceA,对吗?我只需要编辑中间人的清单并在 FE 请求scope=openid api://{MiddlemanId}/.default
    • 我刚试了上面的步骤,在FE没有DownstreamServiceAId/ServiceA.All范围的交互提示
    • @Gavin 我对你的两个 cmets 都不太了解,能否详细说明一下?
    猜你喜欢
    • 2017-08-04
    • 1970-01-01
    • 2019-08-25
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 1970-01-01
    • 2022-07-29
    • 1970-01-01
    相关资源
    最近更新 更多