Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Identityserver 4和Azure AD_C#_Azure Active Directory_Identityserver4 - Fatal编程技术网

C# Identityserver 4和Azure AD

C# Identityserver 4和Azure AD,c#,azure-active-directory,identityserver4,C#,Azure Active Directory,Identityserver4,我正在研究在基于C#的MVC应用程序中使用Identity Server 4进行身份验证。我想使用Azure AD中存储的帐户作为有效用户的来源,但文档似乎只提到了Google和OpenID&只是顺便提到了Azure 是否有人知道在Identity Server 4中使用Azure AD时如何使用Azure AD的良好文档和/或教程 您可以从IdentityServer使用signin to Azure AD,就像从Javascript或MVC应用程序使用signin to IdentitySe

我正在研究在基于C#的MVC应用程序中使用Identity Server 4进行身份验证。我想使用Azure AD中存储的帐户作为有效用户的来源,但文档似乎只提到了Google和OpenID&只是顺便提到了Azure


是否有人知道在Identity Server 4中使用Azure AD时如何使用Azure AD的良好文档和/或教程

您可以从IdentityServer使用signin to Azure AD,就像从Javascript或MVC应用程序使用signin to IdentityServer一样

我最近已经这样做了,您只需将OpenIdConnect选项注册到Azure广告,如下所示:

public void ConfigureAuth(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

    app.UseCookieAuthentication(new CookieAuthenticationOptions());

    app.UseOpenIdConnectAuthentication(
        new OpenIdConnectAuthenticationOptions
        {
            ClientId = clientId,
            Authority = authority,
            PostLogoutRedirectUri = postLogoutRedirectUri,
        });
}
更多信息请点击此处:

然后,您应该在登录操作中调用ChallengeAsync方法:

var authenticationProperties = new AuthenticationProperties { RedirectUri = "your redirect uri" };
await HttpContext.Authentication.ChallengeAsync(your policy, authenticationProperties);
然后提供一个回调方法作为GET方法,然后遵循IdentityServer示例中提供的外部登录示例:

中提供的外部登录示例派生出一个


该示例还修复了一个已知问题

谢谢您提供的信息。我只是从IS4开始,所以我需要问你一些问题:我阅读了关于外部登录的文档,示例显示了一个按钮,我想它会将你重定向到google身份验证页面,因此我也假设你的示例会重定向到microsoft登录页面,还是我错了?如果是真的,是否可以自动对知道其凭据的用户进行身份验证?我的意思是,有人向我的JS应用程序发送用户的凭据(microsoft),然后我将其发送到IS4,它会尝试获取令牌,这才是OpenID Connect的真正意义所在;您将处理密码的麻烦委托给另一个系统,在本例中是Microsoft。您必须添加类似login.microsoft.com或类似的权限,然后在重定向时使用此权限。OpenID连接不是特定于Microsoft的;它只是一个规范,说明了如何使用第三方提供商登录。根据Haok的评论“旧的1.0身份验证堆栈不再工作,在2.0中已经过时”,上面给出的代码示例现在已经过时。这特别涉及上述repo设置IdentityServer startup.cs的Config/cookie身份验证的方式。迁移是在6月17日左右完成的,我可以说是最好的。如果你输入app.UseCookieAuthentication,然后查看构造器上的注释,它会将你带到上面的链接。我仍然对你的帮助投了赞成票,如果我能仅仅从那次回购中插入我需要的代码,那就太棒了。@JakeJ,你可以在GitHub存储库上创建一个问题,要求升级到Core 2.0,甚至提交一个请求。