mirror of
https://github.com/django/django.git
synced 2025-10-30 17:16:10 +00:00
[3.1.x] Fixed #31790 -- Fixed setting SameSite and Secure cookies flags in HttpResponse.delete_cookie().
Cookies with the "SameSite" flag set to None and without the "secure"
flag will be soon rejected by latest browser versions.
This affects sessions and messages cookies.
Backport of 240cbb63bf from master
This commit is contained in:
@@ -758,8 +758,9 @@ class SessionMiddlewareTests(TestCase):
|
||||
# Set-Cookie: sessionid=; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/
|
||||
self.assertEqual(
|
||||
'Set-Cookie: {}=""; expires=Thu, 01 Jan 1970 00:00:00 GMT; '
|
||||
'Max-Age=0; Path=/'.format(
|
||||
'Max-Age=0; Path=/; SameSite={}'.format(
|
||||
settings.SESSION_COOKIE_NAME,
|
||||
settings.SESSION_COOKIE_SAMESITE,
|
||||
),
|
||||
str(response.cookies[settings.SESSION_COOKIE_NAME])
|
||||
)
|
||||
@@ -789,8 +790,9 @@ class SessionMiddlewareTests(TestCase):
|
||||
# Path=/example/
|
||||
self.assertEqual(
|
||||
'Set-Cookie: {}=""; Domain=.example.local; expires=Thu, '
|
||||
'01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/example/'.format(
|
||||
'01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/example/; SameSite={}'.format(
|
||||
settings.SESSION_COOKIE_NAME,
|
||||
settings.SESSION_COOKIE_SAMESITE,
|
||||
),
|
||||
str(response.cookies[settings.SESSION_COOKIE_NAME])
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user