使用Azure Active Directory进行身份验证如何以编程方式接受用户凭据

2024-09-29 21:53:18 发布

您现在位置:Python中文网/ 问答频道 /正文

是否有任何方法可以使用我自己的用户名和密码页(托管在Azure之外)通过web应用程序或web api登录到Azure活动目录(带有AD凭据)?

从我的调查来看,似乎没有编程方法可以发送用户名和密码来通过Azure AD对用户进行身份验证(如果你在Azure之外托管了一个应用程序) 不确定他们是否认为这是某种安全漏洞(我不认为它是强制的https?)

似乎您只能通过代码授权来验证用户身份(这意味着从应用程序中弹出以登录到外部站点)。

最后,我想创建一个python flask api,如果可能的话,它可以直接针对Azure AD进行身份验证。 我以前用Oauth grant_type=password发送用户名和密码(与其他身份验证系统一起)完成过这项工作,但我不认为Azure AD支持这项功能(如果im错误,请更正我?) 我知道grant_type=client_credentials是受支持的,但这看起来像是它的服务到服务身份验证,这不是im所追求的 http://msdn.microsoft.com/en-us/library/azure/dn645543.aspx

如果不可能在Azure之外托管登录页面,那么是否有可能在Azure内部托管一个登录页面,如以下示例所示: http://msdn.microsoft.com/en-us/library/azure/bc8af4ff-66e7-4d5b-b3d4-c33d2c55d270#BKMK_Browser 没有带有密码字段的自定义登录页。。(似乎只有打开的id登录)


Tags: 方法用户身份验证apiweb应用程序http密码
1条回答
网友
1楼 · 发布于 2024-09-29 21:53:18

Azure活动目录支持Resource Owner Password Credentials Grantgrant_type=password)流。但是,在使用之前,请考虑是否确实需要它。正如它在OAuth 2.0 RFC中所说:

The resource owner password credentials (i.e., username and password) can be used directly as an authorization grant to obtain an access token. The credentials should only be used when there is a high degree of trust between the resource owner and the client (e.g., the client is part of the device operating system or a highly privileged application), and when other authorization grant types are not available (such as an authorization code).

如果您已经确定其他支持的流肯定不会对您的场景起作用,那么也一定要遵循RFC中的第二点建议:

Even though this grant type requires direct client access to the resource owner credentials, the resource owner credentials are used for a single request and are exchanged for an access token. This grant type can eliminate the need for the client to store the resource owner credentials for future use, by exchanging the credentials with a long-lived access token or refresh token.

(在两种情况下都增加了强调。)

GitHub上有一个.NET和ADAL示例使用这个流,它应该足够简单,可以在Python中实现:https://github.com/AzureADSamples/NativeClient-Headless-DotNet

编辑:你可以在任何你想要的地方托管你的应用程序,它不需要在Azure上。这适用于所有流。

相关问题 更多 >

    热门问题