0002-debian-add-InternalIpMiddleware-29149.patch
debian/debian_config_common.py | ||
---|---|---|
364 | 364 |
MIDDLEWARE_CLASSES = ( |
365 | 365 |
'hobo.middleware.utils.StoreRequestMiddleware', |
366 | 366 |
'hobo.middleware.xforwardedfor.XForwardedForMiddleware', |
367 |
'hobo.middleware.debug.InternalIPMiddleware', |
|
367 | 368 |
) + MIDDLEWARE_CLASSES |
368 | 369 | |
369 | 370 |
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ( |
hobo/middleware/debug.py | ||
---|---|---|
1 |
# hobo - portal to configure and deploy applications |
|
2 |
# Copyright (C) 2019 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
from django.conf import settings |
|
18 | ||
19 | ||
20 |
class InternalIPMiddleware(object): |
|
21 |
def process_request(self, request): |
|
22 |
internal_ips = getattr(settings, 'INTERNAL_IPS', []) |
|
23 |
try: |
|
24 |
if request.META['REMOTE_ADDR'] in internal_ips: |
|
25 |
self.old_value = settings.DEBUG |
|
26 |
settings.DEBUG = True |
|
27 |
except TypeError: |
|
28 |
pass |
|
29 |
return None |
|
30 | ||
31 |
def process_response(self, request, response): |
|
32 |
if hasattr(self, 'old_value'): |
|
33 |
settings.DEBUG = self.old_value |
|
34 |
del self.old_value |
|
35 |
return response |
|
0 |
- |