Skip to content

Commit b2e06b2

Browse files
vhsantospennersr
authored and
pennersr
committed
feat: include CSRF_TRUSTED_ORIGINS in callback URL validation is_safe_url
Co-authored-by: VHS <listas.vhs@gmail.com> Co-committed-by: VHS <listas.vhs@gmail.com>
1 parent 440f12d commit b2e06b2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

allauth/account/adapter.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,13 @@ def is_safe_url(self, url):
587587
# get_host already validates the given host, so no need to check it again
588588
allowed_hosts = {context.request.get_host()} | set(settings.ALLOWED_HOSTS)
589589

590+
# Include hosts derived from CSRF_TRUSTED_ORIGINS
591+
trusted_hosts = {
592+
urlparse(origin).netloc for origin in settings.CSRF_TRUSTED_ORIGINS
593+
}
594+
allowed_hosts.update(trusted_hosts)
595+
596+
# Handle wildcard case
590597
if "*" in allowed_hosts:
591598
parsed_host = urlparse(url).netloc
592599
allowed_host = {parsed_host} if parsed_host else None

0 commit comments

Comments
 (0)