You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [1]: importwebob.responseIn [2]: r=webob.response.Response()
In [3]: r.set_cookie("foo", "val", overwrite=True, secure=True, samesite='none')
In [4]: r.set_cookie("bar", "val", overwrite=True, secure=True, samesite='none')
In [5]: r.set_cookie("bar", "val1", overwrite=True, secure=True, samesite='none')
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
<ipython-input-5-c3dfd44d63d1>in<module>---->1r.set_cookie("bar", "val", overwrite=True, secure=True, samesite='none')
/opt/webapp/userweb/lib/python3.6/site-packages/webob/response.pyinset_cookie(self, name, value, max_age, path, domain, secure, httponly, comment, expires, overwrite, samesite)
10391040ifoverwrite:
->1041self.unset_cookie(name, strict=False)
10421043# If expires is set, but not max_age we set max_age to expires/opt/webapp/userweb/lib/python3.6/site-packages/webob/response.pyinunset_cookie(self, name, strict)
1087delself.headers['Set-Cookie']
1088formincookies.values():
->1089self.headerlist.append(('Set-Cookie', m.serialize()))
1090elifstrict:
1091raiseKeyError("No cookie has been set with the name %r"%name)
/opt/webapp/userweb/lib/python3.6/site-packages/webob/cookies.pyinserialize(self, full)
297ifnotself.secureandself.samesite.lower() ==b"none":
298raiseValueError(
-->299"Incompatible cookie attributes: "300"when the samesite equals 'none', then the secure must be True"301 )
ValueError: Incompatiblecookieattributes: whenthesamesiteequals'none', thenthesecuremustbeTrue
In [19]: r=webob.response.Response()
In [20]: r.set_cookie("bar", "val", overwrite=True, secure=True, samesite='lax')
In [21]: r.set_cookie("foo", "val", overwrite=True, secure=True, samesite='lax')
In [22]: r.headerlistOut[22]:
[('Content-Type', 'text/html; charset=UTF-8'),
('Content-Length', '0'),
('Set-Cookie', 'bar=val; Path=/; secure; SameSite=lax'),
('Set-Cookie', 'foo=val; Path=/; secure; SameSite=lax')]
In [23]: r.set_cookie("bar", "val", overwrite=True, secure=True, samesite='lax')
In [24]: r.headerlistOut[24]:
[('Content-Type', 'text/html; charset=UTF-8'),
('Content-Length', '0'),
('Set-Cookie', 'foo=val; Path=/; SameSite=lax'),
('Set-Cookie', 'bar=val; Path=/; secure; SameSite=lax')]
It seems like when overwrite=True in set_cookie, the unset_cookie function loads the existing Set-Cookie headers without any of the equal-signless cookie attributes (HttpOnly and Secure).
So if you have an existing Set-Cookie header with SameSite=none and Secure, the Secure gets dropped and then on re-serialization, it raises a ValueError. Or if you don't run into that exception, it silently drops the HttpOnly and Secure flags.
The text was updated successfully, but these errors were encountered:
(using webob-1.8.6, py36 and py37)
It seems like when
overwrite=True
inset_cookie
, theunset_cookie
function loads the existingSet-Cookie
headers without any of the equal-signless cookie attributes (HttpOnly
andSecure
).So if you have an existing
Set-Cookie
header withSameSite=none
andSecure
, theSecure
gets dropped and then on re-serialization, it raises aValueError
. Or if you don't run into that exception, it silently drops theHttpOnly
andSecure
flags.The text was updated successfully, but these errors were encountered: