forked from omab/django-social-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/djm/django-social-auth in…
…to djm-master
- Loading branch information
Showing
2 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import urlparse | ||
|
||
def sanitize_redirect(host, redirect_to): | ||
""" | ||
Given the hostname and an untrusted URL to redirect to, | ||
this method tests it to make sure it isn't garbage/harmful | ||
and returns it, else returns None. | ||
See http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/views.py#L36 | ||
""" | ||
# Quick sanity check. | ||
if not redirect_to: | ||
return None | ||
netloc = urlparse.urlparse(redirect_to)[1] | ||
# Heavier security check -- don't allow redirection to a different host. | ||
if netloc and netloc != host: | ||
return None | ||
return redirect_to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters