Asp.net core 从Asp.Net核心应用程序中的Azure Ad登录获取用户的电子邮件

Asp.net core 从Asp.Net核心应用程序中的Azure Ad登录获取用户的电子邮件,asp.net-core,azure-active-directory,openid-connect,Asp.net Core,Azure Active Directory,Openid Connect,我们有一个具有用户名/密码身份验证的现有Asp.net核心应用程序(使用SignInManager和UserManager以及Microsoft.AspNetCore.Identity v2.2.0中的其他类)。我现在添加了AzureAd,通过添加 services.AddSignIn(Configuration, "AzureAd"); 及 这个配置 "AzureAd": { "Instance": "https://

我们有一个具有用户名/密码身份验证的现有Asp.net核心应用程序(使用SignInManager和UserManager以及Microsoft.AspNetCore.Identity v2.2.0中的其他类)。我现在添加了AzureAd,通过添加

services.AddSignIn(Configuration, "AzureAd");

这个配置

"AzureAd": {
  "Instance": "https://login.microsoftonline.com/",
  "Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
  "TenantId": "organizations",
  "ClientId": "xxx",
  "CallbackPath": "/signin-oidc",
  "SignedOutCallbackPath ": "/signout-callback-oidc"
}
现在AzureAd中的身份验证似乎正在工作,它正在发回/signin oidc,但该端点无法登录用户

我如何将自己的自定义代码连接到回调,以便获得AzureAd已验证的用户的电子邮件地址?然后,如果我信任回调,那么我可以使用电子邮件登录用户


另外一个问题是,我能相信所有回调实际上都来自AzureAd吗?

我在Microsoft Identity Web中找到了一些自定义代码:

AddSignIn has another override, which takes delegates instead of a configuration section. The override with a configuration section actually calls the override with delegates.

为了确保正确的回调请求-基于获取的访问令牌,您可以对“/me”端点执行MS Graph请求,以获取用户数据

以下是许多情况下ASP.net核心的Microsoft代码示例:

我在Microsoft Identity Web中找到了一些自定义代码:

AddSignIn has another override, which takes delegates instead of a configuration section. The override with a configuration section actually calls the override with delegates.

为了确保正确的回调请求-基于获取的访问令牌,您可以对“/me”端点执行MS Graph请求,以获取用户数据

以下是许多情况下ASP.net核心的Microsoft代码示例: