des*_*lan 5 azure claims-based-identity asp.net-core azure-functions
我有一个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的任何指南?
| 归档时间: |
|
| 查看次数: |
1933 次 |
| 最近记录: |