[SECURITY] Fix unvalidated redirect

This commit is contained in:
Raphael Michel
2020-12-22 11:17:16 +01:00
parent 0291676e2d
commit 13441bf3c4
2 changed files with 7 additions and 1 deletions
+3 -1
View File
@@ -74,7 +74,9 @@ def login(request):
backend = [b for b in backends if b.visible][0]
if request.user.is_authenticated:
next_url = backend.get_next_url(request) or 'control:index'
return redirect(next_url)
if next_url and url_has_allowed_host_and_scheme(next_url, allowed_hosts=None):
return redirect(next_url)
return redirect(reverse('control:index'))
if request.method == 'POST':
form = LoginForm(backend=backend, data=request.POST)
if form.is_valid() and form.user_cache and form.user_cache.auth_backend == backend.identifier: