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
Carlos Ramos Carreño
erp5
Commits
ba498122
Commit
ba498122
authored
Apr 02, 2015
by
Julien Muchembled
Committed by
Cédric Le Ninivin
Apr 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Balancer Cookie
parent
7590c250
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
product/ERP5Type/patches/CookieCrumbler.py
product/ERP5Type/patches/CookieCrumbler.py
+27
-0
No files found.
product/ERP5Type/patches/CookieCrumbler.py
View file @
ba498122
...
...
@@ -70,6 +70,31 @@ def getLoginURL(self):
CookieCrumbler
.
getLoginURL
=
getLoginURL
def
balancer_cookie_hook
(
ob
,
req
,
resp
):
"""Post publishing traversal hook to automatically (un)set balancer cookie
If authenticated, then cookie is set to use the same zope on next request,
for a better use of caches. Otherwise, if anonymous, expire cookie so that
the balancer redirects us on any zope.
XXX: Because we only have persistent traversal hooks and we don't want to
complicate code with automatic upgrade, this one is implemented by
pluging into CookieCrumbler, although what they are quite unrelated.
"""
balancer_cookie
=
req
.
get
(
'HTTP_X_BALANCER_CURRENT_COOKIE'
)
if
balancer_cookie
:
try
:
path
=
ob
.
aq_parent
.
absolute_url_path
()
except
AttributeError
:
path
=
'/'
if
req
[
'AUTHENTICATED_USER'
].
getUserName
()
==
'Anonymous User'
:
if
balancer_cookie
in
req
.
cookies
:
resp
.
expireCookie
(
balancer_cookie
,
path
=
path
)
else
:
server_id
=
req
[
'HTTP_X_BALANCER_CURRENT_SERVER'
]
if
server_id
!=
req
.
cookies
.
get
(
balancer_cookie
):
resp
.
setCookie
(
balancer_cookie
,
server_id
,
path
=
path
);
def
modifyRequest
(
self
,
req
,
resp
):
"""Copies cookie-supplied credentials to the basic auth fields.
...
...
@@ -83,6 +108,8 @@ def modifyRequest(self, req, resp):
or
req
.
environ
.
has_key
(
'WEBDAV_SOURCE_PORT'
)):
raise
CookieCrumblerDisabled
req
.
post_traverse
(
balancer_cookie_hook
,
(
self
,
req
,
resp
))
# attempt may contain information about an earlier attempt to
# authenticate using a higher-up cookie crumbler within the
# same request.
...
...
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