Ticket #10629: auth_redirect_ssl.diff
File auth_redirect_ssl.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/views.py
1 import urlparse 2 1 3 from django.conf import settings 2 4 from django.contrib.auth import REDIRECT_FIELD_NAME 3 5 from django.contrib.auth.decorators import login_required … … 20 22 if request.method == "POST": 21 23 form = AuthenticationForm(data=request.POST) 22 24 if form.is_valid(): 23 # Light security check -- make sure redirect_to isn't garbage. 24 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: 25 if not redirect_to: 25 26 redirect_to = settings.LOGIN_REDIRECT_URL 27 else: 28 # Light security check -- make sure redirect_to 29 # doesn't reference a third-party site. 30 url = urlparse.urlparse(redirect_to) 31 if url.netloc and url.netloc != request.get_host(): 32 redirect_to = settings.LOGIN_REDIRECT_URL 26 33 from django.contrib.auth import login 27 34 login(request, form.get_user()) 28 35 if request.session.test_cookie_worked(): -
django/contrib/auth/decorators.py
65 65 def __call__(self, request, *args, **kwargs): 66 66 if self.test_func(request.user): 67 67 return self.view_func(request, *args, **kwargs) 68 path = urlquote(request.get_full_path())69 tup = self.login_url, self.redirect_field_name, path68 cur_url = "%s://%s%s" % (request.is_secure() and "https" or "http",request.get_host(),request.get_full_path()) 69 tup = self.login_url, self.redirect_field_name, urlquote(cur_url) 70 70 return HttpResponseRedirect('%s?%s=%s' % tup)