我有一个基于 django 的 Web 应用程序,客户要求我们将登录与 Azure AD 集成,按照我设法与以下流程集成的文档。
在 django 中,用户仅输入电子邮件,我识别用户及其公司并将他重定向到 microsoft ad 登录屏幕,登录后,重定向 uri 被激活,在我看来,我做了一些验证并在我的系统上对用户进行身份验证。问题是,客户每次登录时都需要在azure中输入凭据,是否可以使用microsoft user_id或用户第一次登录时获取的令牌进行登录?或者还有其他更快登录的方式?
这是我的回调视图,在redirect_uri中调用:
def callback(request):
user_id = request.session.pop('user_id', '')
user_internal = User.objects.filter(id=user_id).first()
company_azure = CompanyAzureAd.objects.filter(company=user_internal.employee.firm).first()
# Get the state saved in session
expected_state = request.session.pop('auth_state', '')
# Make the token request
url = request.build_absolute_uri(request.get_full_path())
token = get_token_from_code(url, expected_state, company_azure)
# Get the user's profile
user = get_user(token) #in this moment i have user microsoft profile, with token and id
# Save token and user
store_token(request, token)
store_user(request, user)
...
如果可以登录,我可以将 Microsoft 中的令牌或用户 ID 存储在我的数据库中,因此只需要登录一次
我认为这已经得到解答here https://stackoverflow.com/questions/60008677/how-should-i-be-implementing-user-sso-with-aad-in-a-django-application-using-th
也试试这个Django 的 ADFS 身份验证 https://django-auth-adfs.readthedocs.io/en/latest/
甚至你也可以尝试 python 中的库
Django 微软身份验证后端 https://pypi.org/project/django-microsoft-auth/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)