英文:
Azure App Service web app: Django + Microsoft login redirect HTTPS issue
问题
Azure应用注册的Web重定向URL(它是HTTPS),如下所示:
使用Azure应用服务成功部署了Django Web应用程序:
上述部署结果显示http://,但在Azure Web应用程序中显示https://,还可以成功使用有效的https://打开Web应用程序,如下所示:
但是,当Web应用程序重定向到Microsoft站点以进行登录时,它再次使用http://,这与应用程序注册中配置的https://不匹配:
MS身份验证和重定向由ms_identity_web
包处理,代码提供自https://github.com/Azure-Samples/ms-identity-python-django-tutorial/tree/main/1-Authentication/sign-in
在开发环境中没有问题,因为我在应用注册中将Web重定向URL设置为http://localhost:8000/auth/redirect。
我的问题可能与这个问题相同:链接,但它涵盖了URL详细信息,因此不确定是否是相同的http/https不匹配问题。
英文:
Azure App registration web redirect URL (it's HTTPS) as below:
Using Azure App Service deployed the Django web app successfully:
the above deploying result shows http://, but in Azure web app web it shows https://, also could open the web app using https successfully with valid as below:
But when the web app redirected to Microsoft site to login, it uses http:// again which doesn't match the https:// configured in App registration:
The MS authentication and redirection is handled by package ms_identity_web
, code
provided from https://github.com/Azure-Samples/ms-identity-python-django-tutorial/tree/main/1-Authentication/sign-in
In development environment there is no issue since I use http://localhost:8000/auth/redirect as web redirect url in App registration.
My issue could be the same as this one: link, but it covered the URL details so not sure if it was the same http/https mismatching issue.
答案1
得分: 0
已通过将以下内容添加到 settings.py 中解决了此问题:
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
参考链接:https://github.com/Azure-Samples/ms-identity-python-django-tutorial/issues/5
英文:
Solved the issue by adding the below into settings.py
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
reference: https://github.com/Azure-Samples/ms-identity-python-django-tutorial/issues/5
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论