如何在Identity Server4中使用ASP.NET Idenity使用Azure AD外部登录
为了在IdenityServer4中使用asp.net标识,我将阅读以下文章: 现在我想将Azure AD添加为外部Idp:如何在Identity Server4中使用ASP.NET Idenity使用Azure AD外部登录,azure,asp.net-core,asp.net-identity,azure-active-directory,identityserver4,Azure,Asp.net Core,Asp.net Identity,Azure Active Directory,Identityserver4,为了在IdenityServer4中使用asp.net标识,我将阅读以下文章: 现在我想将Azure AD添加为外部Idp: services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryPersistedGrants() .AddInMemoryIdentityResources(Config.GetIdentityResources
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryPersistedGrants()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.AddAspNetIdentity<ApplicationUser>();
services.AddAuthentication()
.AddOpenIdConnect("AAD", "Azure Active Directory", options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.SignOutScheme = IdentityServerConstants.SignoutScheme;
options.Authority = "https://login.microsoftonline.com/xxxxxx.onmicrosoft.com";
options.ClientId = "xxxxxxx";
options.Scope.Add("openid");
options.Scope.Add("profile");
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false
};
options.GetClaimsFromUserInfoEndpoint = true;
});
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryStedGrants()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.addAsNetIdentity();
services.AddAuthentication()
.AddOpenIdConnect(“AAD”,“Azure Active Directory”,选项=>
{
options.signnscheme=IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.SignOutScheme=IdentityServerConstants.SignOutScheme;
选项。权限=”https://login.microsoftonline.com/xxxxxx.onmicrosoft.com";
options.ClientId=“xxxxxxx”;
options.Scope.Add(“openid”);
选项。范围。添加(“配置文件”);
options.TokenValidationParameters=新的TokenValidationParameters
{
validateisuer=false
};
options.GetClaimsFromUserInfoEndpoint=true;
});
但当我调试我的应用程序==>重定向到identity server==>时,单击AAD登录。我注意到当我到达Azure AD用户名/密码页面时,我的客户端应用程序停止,因此在输入凭据和同意后,我将停留在identity server页面。有人能提供一些建议吗?我看到你评论了你的Microsoft权威URL,好像它是针对你的公司的。我已经为我公司的认证配置了Azure AD外部登录,我只需要打电话 此外,如果它正在将fine重定向到Microsoft的站点,而没有返回到Auth服务器,则您可能没有在控制器的ExternalLogin函数中正确设置某些内容 它应该是这样的:
var props = new AuthenticationProperties()
{
RedirectUri = Url.Action("ExternalLoginCallback"),
Items =
{
{ "returnUrl", returnUrl },
{ "scheme", provider },
}
};
return Challenge(props, provider);
提供商将是您的“AAD”。有趣的是,当我在visual studio中使用chrome启动客户端应用程序时,客户端应用程序不再停止。很奇怪,也找不到解释。也许这个示例可以帮助您:@MartinBrandl,谢谢,我尝试了解决方案,但代码显示错误,函数为obsolteMaybe您必须设置选项。示例中的RepsonseType属性Azure AD中的配置如何?如何在那里配置Identity Server?您使用的OAuth2流是什么?@ChaimZonnenberg,Azure AD配置是正确的。如上所示,提供了配置的Identity Server。我使用混合流。