Skip to content

Commit 2775104

Browse files
committed
sanitize the url before allowing redirect
1 parent fc240a6 commit 2775104

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

authentication/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.conf import settings
66
from django.contrib.auth import views
77
from django.shortcuts import redirect
8+
from social_core.utils import sanitize_redirect
89
from social_django.utils import load_strategy
910

1011
from authentication.backends.ol_open_id_connect import OlOpenIdConnectAuth
@@ -34,6 +35,9 @@ def _keycloak_logout_url(self, user):
3435
).first()
3536
id_token = user_social_auth_record.extra_data.get("id_token")
3637
qs_next = self.request.GET.get("next")
38+
if qs_next:
39+
allowed_hosts = settings.SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS or []
40+
qs_next = sanitize_redirect(allowed_hosts, qs_next)
3741
qs = urlencode(
3842
{
3943
"id_token_hint": id_token,

0 commit comments

Comments
 (0)