我正在开发使用SPA的SPA,该API使用Azure Function应用程序的API,使用Azure Active Directory进行身份验证。用户登录后,在本地存储中设置了adal.access.token
,但是未在绑定的ClaimsPrincipal
参数中正确设置声明,也未在HttpRequest参数中设置声明。无论是否设置了Authorization: Bearer ...
标头,claims主对象看起来都相同。如何配置我的功能应用程序以使用AAD和ClaimsPrincipal
绑定?我通过使用jwt.io
处的令牌调试器验证了声明已在访问令牌中设置。
public static MyFunction { [FunctionName("MyFunction")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "some-path")], ClaimsPrincipal principal ){ // principal does not contain the claims, or any of the token info } }
然后我发送请求:
curl -X GET -H "Authorization: Bearer ..." http://localhost:7071/api/some-path But the claims principle only has one claim, `http://schemas.microsoft.com/2017/07/functions/claims/authlevel: Admin`
更新:似乎在Azure中调用时按预期设置了主体变量,但在本地进行开发时未设置。
我正在开发使用SPA的SPA,该API使用Azure Function应用程序的API,使用Azure Active Directory进行身份验证。用户登录后,在本地存储中设置了adal.access.token,但未设置声明...
i假设您通过使用带有Express或其他功能的天蓝色广告激活身份验证,使用功能服务应用程序控制面板创建了应用程序注册。这样做会创建应用注册,并将应用功能作为回复网址,因此,如果您在开发环境中本地运行它并尝试登录,它将永远不会将令牌作为源URL发送到本地计算机。