mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-19 22:48:01 +00:00
Merge branch 'devel' into 'master'
Fix middleware to do exactly what we want/need See merge request oliver/ivatar!79
This commit is contained in:
@@ -6,21 +6,13 @@ from django.utils.deprecation import MiddlewareMixin
|
|||||||
class MultipleProxyMiddleware(MiddlewareMixin): # pylint: disable=too-few-public-methods
|
class MultipleProxyMiddleware(MiddlewareMixin): # pylint: disable=too-few-public-methods
|
||||||
"""
|
"""
|
||||||
Middleware to rewrite proxy headers for deployments
|
Middleware to rewrite proxy headers for deployments
|
||||||
multiple proxies
|
with multiple proxies
|
||||||
"""
|
"""
|
||||||
FORWARDED_FOR_FIELDS = [
|
|
||||||
'HTTP_X_FORWARDED_FOR',
|
|
||||||
'HTTP_X_FORWARDED_HOST',
|
|
||||||
'HTTP_X_FORWARDED_SERVER',
|
|
||||||
]
|
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
"""
|
"""
|
||||||
Rewrites the proxy headers so that only the most
|
Rewrites the proxy headers so that forwarded server is
|
||||||
recent proxy is used.
|
used if available.
|
||||||
"""
|
"""
|
||||||
for field in self.FORWARDED_FOR_FIELDS:
|
if 'HTTP_X_FORWARDED_SERVER' in request.META:
|
||||||
if field in request.META:
|
request.META['HTTP_X_FORWARDED_HOST'] = request.META['HTTP_X_FORWARDED_SERVER']
|
||||||
if ',' in request.META[field]:
|
|
||||||
parts = request.META[field].split(',')
|
|
||||||
request.META[field] = parts[-1].strip()
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<button type="submit" class="btn btn-default">{% trans 'Login' %}</button>
|
<button type="submit" class="btn btn-default">{% trans 'Login' %}</button>
|
||||||
<input type="hidden" name="next" value="{{ next }}" />
|
<input type="hidden" name="next" value="{{ request.build_absolute_uri }}{% url 'profile' %}" />
|
||||||
|
|
||||||
<button type="reset" class="btn btn-default" onclick="window.history.back();">{% trans 'Cancel' %}</button>
|
<button type="reset" class="btn btn-default" onclick="window.history.back();">{% trans 'Cancel' %}</button>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user