Azure AD B2C 中的非交互式身份验证和授权

问题描述 投票:0回答:1

AD B2C 是否可以用于非交互式身份验证?即我想传递用户名(电子邮件 ID)/密码并通过应用程序(不是 API 后端,而是绕过登录流程的 Web 应用程序)进行身份验证 - 基本上自动登录用户与用户/密码的交互并重定向到资源)

我已经使用了ROPC作为后端API,可以使用它还是有其他方法。

我们可以从类似于以下的调用中获取访问权限和 ID 令牌吗:

https://<tenant-name>.b2clogin.com/<tenant-name>.onmicrosoft.com/<policy-name>/oauth2/v2.0/authorize?
client_id=<application-ID>
&nonce=anyRandomValue
&redirect_uri=https://jwt.ms
&scope=<application-ID-URI>/<scope-name>
&response_type=code

无需交互流程并提供重定向URL。

oauth-2.0 azure-active-directory azure-ad-b2c openid-connect azure-ad-b2c-custom-policy
1个回答
0
投票

是的,您也可以对 Web 应用程序使用相同的流程以非交互方式获取访问权限和 ID 令牌。

我尝试在我的环境中重现相同的结果并得到以下结果:

我在我的 B2C 租户中注册了一个 Web 应用程序,并在

Web
平台中添加了重定向 URI,如下所示:

enter image description here

在清单中,确保启用隐式流程,如下所示:

enter image description here

我公开了一个 API 并将该 API 权限授予

WebApp
,如下所示:

enter image description here

现在,我创建了一个资源所有者用户流程,如下所示:

enter image description here

我通过 Postman 成功获得了 accessid 令牌,参数如下:

POST https://b2ctenantname.b2clogin.com/b2ctenantname.onmicrosoft.com/<ROPC_policyname>/oauth2/v2.0/token
client_id:<App_ID>
redirect_uri: https://jwt.ms
grant_type:password
username: <UPN_of_B2C user> 
password:xxxxxxxxxxxx
scope:openid https://b2ctenantname.onmicrosoft.com/appID/Custom.Scope
response_type:token id_token

回复:

enter image description here

当我解码上述访问令牌时,我成功获得了

scp
声明,自定义范围如下:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.