如何在不使用 Microsoft 登录页面的情况下使用 Azure Active Directory 登录 Web 应用程序?

How to login the webapp using Azure Active active directory without using Microsft login page?

我们创建了一个 .net MVC 4.6.1 Web 应用程序,它使用 Azure 活动目录进行身份验证。当我们 运行 应用程序时,它会重定向到 Microsoft 登录页面,并在成功登录后进入 webapp。我的问题是我们是否可以通过使用 API 调用来使用 Azure 活动目录进行身份验证,我们将创建简单的登录页面,在后端我将使用用户名和密码调用 api。根据结果​​我可以判断用户是否有效?

您可以使用自己的登录页面获取用户的 username/password ,然后将 [Resource Owner Password Credentials Grant][1] 与 Azure AD 一起使用。但是,出于安全考虑,不鼓励使用该流程和功能原因。请参考[文档][2] :

The resource owner password credentials grant type is suitable in cases where the resource owner has a trust relationship with the client, such as the device operating system or a highly privileged application. The authorization server should take special care when enabling this grant type and only allow it when other flows are not viable. [1]: https://blogs.msdn.microsoft.com/wushuai/2016/09/25/resource-owner-password-credentials-grant-in-azure-ad-oauth/ [2]: https://www.rfc-editor.org/rfc/rfc6749#section-4.3