summaryrefslogtreecommitdiff
path: root/lib/ssl/middleware.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2012-09-22 22:27:04 -0400
committerluxagraf <sng@luxagraf.net>2012-09-22 22:27:04 -0400
commitefb623af0bcb47d510501c282e1326b11343a29c (patch)
tree3a35fb19f5eba3b219c65277a5fb712cbe9604ac /lib/ssl/middleware.py
parent0b481fd7931c2ae20ca21f89a87f2ba6a6c01e10 (diff)
site reorg
Diffstat (limited to 'lib/ssl/middleware.py')
-rw-r--r--lib/ssl/middleware.py41
1 files changed, 0 insertions, 41 deletions
diff --git a/lib/ssl/middleware.py b/lib/ssl/middleware.py
deleted file mode 100644
index 11e1076..0000000
--- a/lib/ssl/middleware.py
+++ /dev/null
@@ -1,41 +0,0 @@
-__license__ = "Python"
-__copyright__ = "Copyright (C) 2007, Stephen Zabel"
-__author__ = "Stephen Zabel - sjzabel@gmail.com"
-__contributors__ = "Jay Parlar - parlar@gmail.com"
-
-from django.conf import settings
-from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect, get_host
-
-SSL = 'SSL'
-
-class SSLRedirect:
-
- def process_view(self, request, view_func, view_args, view_kwargs):
- if SSL in view_kwargs:
- secure = view_kwargs[SSL]
- del view_kwargs[SSL]
- else:
- secure = False
-
- if not secure == self._is_secure(request):
- return self._redirect(request, secure)
-
- def _is_secure(self, request):
- if request.is_secure():
- return True
-
- #Handle the Webfaction case until this gets resolved in the request.is_secure()
- if 'HTTP_X_FORWARDED_SSL' in request.META:
- return request.META['HTTP_X_FORWARDED_SSL'] == 'on'
-
- return False
-
- def _redirect(self, request, secure):
- protocol = secure and "https" or "http"
- newurl = "%s://%s%s" % (protocol,get_host(request),request.get_full_path())
- if settings.DEBUG and request.method == 'POST':
- raise RuntimeError, \
- """Django can't perform a SSL redirect while maintaining POST data.
- Please structure your views so that redirects only occur during GETs."""
-
- return HttpResponsePermanentRedirect(newurl) \ No newline at end of file