小编des*_*lan的帖子

Azure Function 2.x-获取当前用户的声明

我有一个Azure Function 2.x(Asp.net Core),并且正在使用Azure AD进行身份验证。我正在尝试在身份验证后访问登录用户的声明。以前使用Azure Functions 1.x,我们将使用ClaimsPrincipal.Current来获得Claims ,如以下代码所示:

using System.Net;
using System.Collections.Generic;
using System.Security.Claims; 
using Microsoft.IdentityModel.Clients.ActiveDirectory; 

public static HttpResponseMessage Run(HttpRequestMessage req, out object document, TraceWriter log)
{
    string name = ClaimsPrincipal.Current.FindFirst("name").Value; 

    log.Info($"name is {name}");

    return req.CreateResponse(HttpStatusCode.OK, "Done");
}   
Run Code Online (Sandbox Code Playgroud)

关于如何使用.Net Core访问Azure Functions 2.x中的Claims的任何指南?

azure claims-based-identity asp.net-core azure-functions

5
推荐指数
1
解决办法
1933
查看次数