ASP.NET核心OpenId身份验证

时间:2018-01-16 12:03:14

标签: asp.net-mvc azure authentication asp.net-core openid-connect

我正在使用针对azure活动目录的身份验证开发.net核心mvc应用程序。我的问题是,我有两个不同的azure avtice目录,它们是相互不同的。根据用户输入(邮件或雇员编号),我将决定应使用哪个活动目录。

任何想法或参考? 谢谢!

2 个答案:

答案 0 :(得分:0)

有一个非常好的可靠的开源项目(Identity Server)

https://github.com/IdentityServer/IdentityServer4

你也可以查看(openiddict)

https://github.com/openiddict/openiddict-core

答案 1 :(得分:0)

您正在描述multi-tenant application AAD common endpoint is used as the entry point to the application而不是特定的AAD登录页面。您可以将应用程序配置为信任多个AAD实例。它涉及很多,但MS在how to adopt a single tenant app to multi-tenant上有很好的文档。我还强烈推荐Vittirio's blog作为了解AAD身份验证的地方,当你正在阅读时,他的书名为“使用Azure Active Directory进行Web应用程序的现代身份验证”

为应用程序启用多租户后,您将需要通过检查传入SSO请求中的租户ID来自行处理AAD验证。您可以通过覆盖UseOpenIdConnectAuthentication中的SecurityTokenValidated来执行此操作。 You can refer to this example where the code validates against a database

还有其他注意事项such as admin consent,其中AAD管理员必须授予对应用程序的受限权限的访问权限。 Good explaination here