root / pithos / middleware / secure.py @ 2e662088
History | View | Annotate | Download (1.7 kB)
1 | 2e662088 | Antony Chazapis | # Copyright 2011-2012 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 1e20eb36 | Antony Chazapis | #
|
3 | 1e20eb36 | Antony Chazapis | # Redistribution and use in source and binary forms, with or
|
4 | 1e20eb36 | Antony Chazapis | # without modification, are permitted provided that the following
|
5 | 1e20eb36 | Antony Chazapis | # conditions are met:
|
6 | 1e20eb36 | Antony Chazapis | #
|
7 | 1e20eb36 | Antony Chazapis | # 1. Redistributions of source code must retain the above
|
8 | 1e20eb36 | Antony Chazapis | # copyright notice, this list of conditions and the following
|
9 | 1e20eb36 | Antony Chazapis | # disclaimer.
|
10 | 1e20eb36 | Antony Chazapis | #
|
11 | 1e20eb36 | Antony Chazapis | # 2. Redistributions in binary form must reproduce the above
|
12 | 1e20eb36 | Antony Chazapis | # copyright notice, this list of conditions and the following
|
13 | 1e20eb36 | Antony Chazapis | # disclaimer in the documentation and/or other materials
|
14 | 1e20eb36 | Antony Chazapis | # provided with the distribution.
|
15 | 1e20eb36 | Antony Chazapis | #
|
16 | 1e20eb36 | Antony Chazapis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 1e20eb36 | Antony Chazapis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 1e20eb36 | Antony Chazapis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 1e20eb36 | Antony Chazapis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 1e20eb36 | Antony Chazapis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 1e20eb36 | Antony Chazapis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 1e20eb36 | Antony Chazapis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 1e20eb36 | Antony Chazapis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 1e20eb36 | Antony Chazapis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 1e20eb36 | Antony Chazapis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 1e20eb36 | Antony Chazapis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 1e20eb36 | Antony Chazapis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 1e20eb36 | Antony Chazapis | #
|
29 | 1e20eb36 | Antony Chazapis | # The views and conclusions contained in the software and
|
30 | 1e20eb36 | Antony Chazapis | # documentation are those of the authors and should not be
|
31 | 1e20eb36 | Antony Chazapis | # interpreted as representing official policies, either expressed
|
32 | 1e20eb36 | Antony Chazapis | # or implied, of GRNET S.A.
|
33 | 1e20eb36 | Antony Chazapis | |
34 | 1e20eb36 | Antony Chazapis | class SecureMiddleware(object): |
35 | 1e20eb36 | Antony Chazapis | def process_request(self, request): |
36 | 1e20eb36 | Antony Chazapis | if 'HTTP_X_FORWARDED_PROTOCOL' in request.META: |
37 | 1e20eb36 | Antony Chazapis | request.is_secure = lambda: request.META['HTTP_X_FORWARDED_PROTOCOL'] == 'https' |