Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
erp5
Commits
2c484ab3
Commit
2c484ab3
authored
Jun 26, 2020
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! ERP5Type/patches: use the first entry of HTTP_X_FORWARDED_FOR as the source IP address.
parent
4a62a6e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
product/ERP5/bin/zopewsgi.py
product/ERP5/bin/zopewsgi.py
+2
-1
product/ERP5Type/ZopePatch.py
product/ERP5Type/ZopePatch.py
+1
-0
product/ERP5Type/patches/WSGITask.py
product/ERP5Type/patches/WSGITask.py
+37
-0
No files found.
product/ERP5/bin/zopewsgi.py
View file @
2c484ab3
...
...
@@ -139,7 +139,8 @@ def createServer(application, logger, **kw):
server
=
create_server
(
TransLogger
(
application
,
logger
=
logger
),
trusted_proxy
=
'*'
,
trusted_proxy_headers
=
(
'x-forwarded-for'
,),
# We handle X-Forwarded-For by ourselves. See ERP5Type/patches/WSGITask.py.
# trusted_proxy_headers=('x-forwarded-for',),
clear_untrusted_proxy_headers
=
True
,
**
kw
)
...
...
product/ERP5Type/ZopePatch.py
View file @
2c484ab3
...
...
@@ -90,6 +90,7 @@ from Products.ERP5Type.patches import ZSQLMethod
from
Products.ERP5Type.patches
import
MimetypesRegistry
from
Products.ERP5Type.patches
import
users
from
Products.ERP5Type.patches
import
Publish
from
Products.ERP5Type.patches
import
WSGITask
# These symbols are required for backward compatibility
from
Products.ERP5Type.patches.PropertyManager
import
ERP5PropertyManager
...
...
product/ERP5Type/patches/WSGITask.py
0 → 100644
View file @
2c484ab3
# -*- coding: utf-8 -*-
import
ZPublisher.HTTPRequest
from
waitress.task
import
WSGITask
WSGITask_parse_proxy_headers
=
WSGITask
.
parse_proxy_headers
def
parse_proxy_headers
(
self
,
environ
,
headers
,
trusted_proxy_count
=
1
,
trusted_proxy_headers
=
None
,
):
if
ZPublisher
.
HTTPRequest
.
trusted_proxies
==
(
'0.0.0.0'
,):
# Magic value to enable this functionality
# Frontend-facing proxy is responsible for sanitising
# X_FORWARDED_FOR, and only trusted accesses should bypass
# that proxy. So trust first entry.
forwarded_for
=
headers
.
get
(
'X_FORWARDED_FOR'
,
''
).
split
(
','
,
1
)[
0
].
strip
()
else
:
forwarded_for
=
None
untrusted_headers
=
WSGITask_parse_proxy_headers
(
self
,
environ
=
environ
,
headers
=
headers
,
trusted_proxy_count
=
trusted_proxy_count
,
trusted_proxy_headers
=
trusted_proxy_headers
,
)
if
forwarded_for
:
environ
[
'REMOTE_ADDR'
]
=
forwarded_for
return
untrusted_headers
WSGITask
.
parse_proxy_headers
=
parse_proxy_headers
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment