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

Fix code scanning alert no. 21: URL redirection from remote source #518

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/core/views/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render, redirect
from django.urls import resolve, reverse
from django.utils.http import url_has_allowed_host_and_scheme
from django.urls.exceptions import Resolver404
from django.utils.decorators import method_decorator
from django.views import View
Expand Down Expand Up @@ -84,6 +85,8 @@ def login_manual(request: HttpRequest):


def redirect_to_login(email: str, redirect_url: str):
if not url_has_allowed_host_and_scheme(redirect_url, allowed_hosts=None):
redirect_url = reverse("dashboard")
return redirect(f"{reverse('auth:login')}?email={email}&next={redirect_url}")


Expand Down
Loading