Azure AD MFA无需浏览器?

huangapple go评论81阅读模式
英文:

Azure AD MFA without a browser?

问题

这个问题之前已经被问过了,但是在不同的背景下。我需要能够在没有加载浏览器的终端上通过多因素身份验证(MFA)来认证到Azure AD(Entra)。我在Linux上使用了Python的msal库。目前我只能使用用户名和密码进行认证。
我已经尝试了一些方法,比如使用selenium等。有人有什么想法吗?

英文:

This has been asked before, but in a different context. I need to be able to authenticate to Azure AD (Entra) via MFA from a terminal, where there is no possibility to load a browser. This is on Linux, and I've been using the python msal library. Right now I can only authenticate with username and password.
I've been grasping at straws, such as using selenium, etc. Anyone have any ideas?

答案1

得分: 2

在不支持Web浏览器的环境中(例如无头Linux服务器上的终端),如果你想使用类似于MSAL的库,你将无法使用依赖于基于浏览器重定向的标准交互式OAuth流程。

对于没有浏览器的终端工具,我通常建议使用"设备代码流"。

  1. 应用程序请求Azure AD提供设备代码。
  2. Azure AD返回设备代码、用户代码和验证URL。
  3. 用户被指示在另一台设备上(如手机或桌面电脑)浏览到验证URL,并输入用户代码。完成后,他们将在该独立设备上完成标准的交互式MFA过程。
  4. 同时,应用程序定期使用设备代码轮询Azure AD,以检查用户是否已完成MFA过程。
  5. 用户完成MFA后,Azure AD将向应用程序返回访问令牌。

了解更多信息,请访问以下链接:
https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code

你还可以在以下链接找到使用Python实现设备代码流的示例代码:
https://github.com/Azure-Samples/ms-identity-python-devicecodeflow

Azure AD MFA无需浏览器?

英文:

Library like MSAL in an environment that doesn't support a web browser (e.g., terminal in a headless Linux server), you won't be able to use the standard interactive OAuth flows which rely on a browser-based redirect.

For Terminal Based tools without browser, I generally recommend using the "Device Code Flow".

  1. The application asks Azure AD to provide a device code.
  2. Azure AD returns a device code, a user code, and a verification URL.
  3. The user is instructed to browse to the verification URL on a separate device (like their phone or a desktop) and input the user code. Upon doing so, they'll then complete the standard interactive MFA process on that separate device.
  4. Meanwhile, the application periodically polls Azure AD with the device code to check if the user has completed the MFA process.
  5. Once the user completes the MFA, Azure AD returns an access token to the application.

https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code

https://github.com/Azure-Samples/ms-identity-python-devicecodeflow

Azure AD MFA无需浏览器?

huangapple
  • 本文由 发表于 2023年8月8日 23:18:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76860951.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定