Why I got "http://~" as redirect url parameter althoguh I set "https://~" to LOGIN_REDIRECT_URL in mozilla-django-oidc?

I've been trying to integrate Django app with Keycloak using mozilla-django-oidc and fix the problem as refered to in the title.

I configured LOGIN_REDIRECT_URL and the configurations that are required in settings.py


LOGIN_REDIRECT_URL = "https://~"

and prepared Django template.


{% if request.user.is_authenticated %}
\<p\>Current user: {{ request.user.email }}\</p\>
\<form action="{{ url('oidc_logout') }}" method="post"\>
{{ csrf_input }}
\<input type="submit" value="logout"\>
\</form\>
{% else %}
\<a href="{{ url('oidc_authentication_init') }}"\>Login\</a\>
{% endif %}

However I clicked the Login link, then I got the error message which says invalid redirect url because redirect url parameter was changed to http://~.

I looked through the code of mozilla-django-oidc, and seemed that there's no function changing "https://~" to "http://~" as redirect url parameter and I set "https://~" to LOGIN_REDIRECT_URL so there might be something wrong with reverse proxy which is Istio in my case. I haven't configured anything by myself so far.

In case of using Ngnix, this problem can be solved like this.

I'd like you to answer what's the cause of problem and how to fix it.

Back to Top