Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http instead Https (AADSTS50011) #243

Closed
zfmbek3 opened this issue Jun 30, 2022 · 1 comment
Closed

Http instead Https (AADSTS50011) #243

zfmbek3 opened this issue Jun 30, 2022 · 1 comment

Comments

@zfmbek3
Copy link

zfmbek3 commented Jun 30, 2022

Hi
I use django_auth_adfs Azure AD for Django authentication.

On my local server authentication works fine.

But when I deploy my app to Azure App service I can not login successfully.

AADSTS50011: The redirect URI 'http://myapp.azurewebsites.net/oauth2/callback' specified in the request does not match the redirect URIs configured for the application ....

But my Redirect url https://myapp.azurewebsites.net/oauth2/callback
HTTPS not HTTP

I looked into the code of the django_auth_adfs and found that the code responsible for redirect_uri parameter is:

django_auth_adfs/config.py
309 def redirect_uri(self, request):
310 self.load_config()
311 return request.build_absolute_uri(reverse("django_auth_adfs:callback"))

Hence request.build_absolute_uri(reverse("django_auth_adfs:callback")) return http://myapp.azurewebsites.net/oauth2/callback

Why HTTP not HTTPS
I do not understand.

What can i do?
Is there any workaround for get correct absolute_uri with HTTPS

@zfmbek3
Copy link
Author

zfmbek3 commented Jun 30, 2022

I solved the problem.
On Azure, your application is running behind a proxy
If I understood correctly

I added
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
to settings.py

Now it work correctly

@zfmbek3 zfmbek3 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant