Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
1057219b
Commit
1057219b
authored
Sep 15, 2016
by
Tres Seaver
Committed by
GitHub
Sep 15, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72 from EcrinDe/2.13
Add support for optional 'SameSite' cookie attribute
parents
99a37fec
1c656163
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+6
-0
src/ZPublisher/tests/testHTTPResponse.py
src/ZPublisher/tests/testHTTPResponse.py
+13
-0
No files found.
doc/CHANGES.rst
View file @
1057219b
...
...
@@ -18,6 +18,9 @@ http://docs.zope.org/zope2/
- Removed docstrings from some methods to avoid publishing them. From
Products.PloneHotfix20160419. [maurits]
- Add support to SameSite cookie in ``ZPublisher.HTTPResponse``:
https://tools.ietf.org/html/draft-west-first-party-cookies-07
2.13.24 (2016-02-29)
--------------------
...
...
src/ZPublisher/HTTPResponse.py
View file @
1057219b
...
...
@@ -903,6 +903,12 @@ class HTTPResponse(BaseResponse):
# and block read/write access via JavaScript
elif name == '
http_only
' and v:
cookie = '
%
s
;
HTTPOnly
' % cookie
# Some browsers recognize the SameSite cookie attribute
# and do not send the cookie along with cross-site requests
# providing some protection against CSRF attacks
# https://tools.ietf.org/html/draft-west-first-party-cookies-07
elif name == '
same_site
':
cookie = '
%
s
;
SameSite
=%
s
' % (cookie, v)
cookie_list.append(('
Set
-
Cookie
', cookie))
# Should really check size of cookies here!
...
...
src/ZPublisher/tests/testHTTPResponse.py
View file @
1057219b
...
...
@@ -319,6 +319,19 @@ class HTTPResponseTests(unittest.TestCase):
self
.
assertEqual
(
len
(
cookie_list
),
1
)
self
.
assertEqual
(
cookie_list
[
0
],
(
'Set-Cookie'
,
'foo="bar"'
))
def
test_setCookie_w_same_site
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
same_site
=
'Strict'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
3
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'same_site'
),
'Strict'
)
self
.
assertEqual
(
cookie
.
get
(
'quoted'
),
True
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
(
'Set-Cookie'
,
'foo="bar"; SameSite=Strict'
))
def
test_setCookie_unquoted
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
quoted
=
False
)
...
...
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