Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Delete ReverseProxyMiddleware and StaySecureMiddleware.

not used!!
  • Loading branch information...
commit 7742a42f0306a38e75950b5a651ae1726d9895b1 1 parent 0125882
@rlr rlr authored
View
10 apps/sumo/middleware.py
@@ -146,16 +146,6 @@ def process_response(self, request, response):
return response
-class ReverseProxyMiddleware(object):
- """Monkey-patches request.is_secure() when we're running behind a
- reverse proxy like nginx or Apache with mod_proxy.
- """
- def process_request(self, request):
- if 'HTTP_X_SCHEME' in request.META:
- is_secure = lambda: request.META['HTTP_X_SCHEME'] == 'https'
- request.is_secure = is_secure
-
-
@contextlib.contextmanager
def safe_query_string(request):
"""
View
21 apps/users/middleware.py
@@ -1,21 +0,0 @@
-from django.conf import settings
-from django.http import HttpResponseRedirect
-
-
-class StaySecureMiddleware(object):
- """Detects a cookie indicating a user has a session and stays secure.
-
- Should be below ReverseProxyMiddleware if it's used.
-
- """
- def process_request(self, request):
- SEC = settings.SESSION_EXISTS_COOKIE
- need_https = settings.SESSION_COOKIE_SECURE and SEC in request.COOKIES
- if need_https and not request.is_secure():
- host = request.META['SERVER_NAME']
- path = request.META['PATH_INFO']
- qs = request.META['QUERY_STRING']
- if qs:
- path = u'%s?%s' % (path, qs)
- url = u'https://%s%s' % (host, path)
- return HttpResponseRedirect(url)
View
35 apps/users/tests/test_middleware.py
@@ -1,35 +0,0 @@
-from django.conf import settings
-
-import mock
-from nose.tools import eq_
-from test_utils import RequestFactory
-
-from sumo.tests import TestCase
-from users.middleware import StaySecureMiddleware
-
-
-class StaySecureTests(TestCase):
- rf = RequestFactory()
- ssm = StaySecureMiddleware()
-
- @mock.patch.object(settings._wrapped, 'SESSION_COOKIE_SECURE', True)
- def test_redirect_if_session(self):
- get = self.rf.get('/foo')
- assert not get.is_secure()
- resp = self.ssm.process_request(get)
- assert not resp
-
- get.COOKIES[settings.SESSION_EXISTS_COOKIE] = u'1'
- resp = self.ssm.process_request(get)
- assert resp
- eq_(302, resp.status_code)
- assert resp['location'].startswith('https://')
-
- @mock.patch.object(settings._wrapped, 'SESSION_COOKIE_SECURE', True)
- def test_maintain_query_string(self):
- get = self.rf.get('/foo?bar=baz')
- assert not get.is_secure()
- get.COOKIES[settings.SESSION_EXISTS_COOKIE] = u'1'
- resp = self.ssm.process_request(get)
- assert resp
- assert resp['location'].endswith('bar=baz')
Please sign in to comment.
Something went wrong with that request. Please try again.