Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
2dee853e
Kaydet (Commit)
2dee853e
authored
May 14, 2015
tarafından
Bo Lopker
Kaydeden (comit)
Tim Graham
May 15, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24799 -- Fixed session cookie deletion when using SESSION_COOKIE_DOMAIN
üst
ae635cc3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
middleware.py
django/contrib/sessions/middleware.py
+2
-1
1.8.2.txt
docs/releases/1.8.2.txt
+3
-0
tests.py
tests/sessions_tests/tests.py
+29
-0
No files found.
django/contrib/sessions/middleware.py
Dosyayı görüntüle @
2dee853e
...
@@ -31,7 +31,8 @@ class SessionMiddleware(object):
...
@@ -31,7 +31,8 @@ class SessionMiddleware(object):
# First check if we need to delete this cookie.
# First check if we need to delete this cookie.
# The session should be deleted only if the session is entirely empty
# The session should be deleted only if the session is entirely empty
if
settings
.
SESSION_COOKIE_NAME
in
request
.
COOKIES
and
empty
:
if
settings
.
SESSION_COOKIE_NAME
in
request
.
COOKIES
and
empty
:
response
.
delete_cookie
(
settings
.
SESSION_COOKIE_NAME
)
response
.
delete_cookie
(
settings
.
SESSION_COOKIE_NAME
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
)
else
:
else
:
if
accessed
:
if
accessed
:
patch_vary_headers
(
response
,
(
'Cookie'
,))
patch_vary_headers
(
response
,
(
'Cookie'
,))
...
...
docs/releases/1.8.2.txt
Dosyayı görüntüle @
2dee853e
...
@@ -30,3 +30,6 @@ Bugfixes
...
@@ -30,3 +30,6 @@ Bugfixes
* Fixed a MySQL crash when a migration removes a combined index (unique_together
* Fixed a MySQL crash when a migration removes a combined index (unique_together
or index_together) containing a foreign key (:ticket:`24757`).
or index_together) containing a foreign key (:ticket:`24757`).
* Fixed session cookie deletion when using :setting:`SESSION_COOKIE_DOMAIN`
(:ticket:`24799`).
tests/sessions_tests/tests.py
Dosyayı görüntüle @
2dee853e
...
@@ -613,6 +613,35 @@ class SessionMiddlewareTests(TestCase):
...
@@ -613,6 +613,35 @@ class SessionMiddlewareTests(TestCase):
str
(
response
.
cookies
[
settings
.
SESSION_COOKIE_NAME
])
str
(
response
.
cookies
[
settings
.
SESSION_COOKIE_NAME
])
)
)
@override_settings
(
SESSION_COOKIE_DOMAIN
=
'.example.local'
)
def
test_session_delete_on_end_with_custom_domain
(
self
):
request
=
RequestFactory
()
.
get
(
'/'
)
response
=
HttpResponse
(
'Session test'
)
middleware
=
SessionMiddleware
()
# Before deleting, there has to be an existing cookie
request
.
COOKIES
[
settings
.
SESSION_COOKIE_NAME
]
=
'abc'
# Simulate a request that ends the session
middleware
.
process_request
(
request
)
request
.
session
.
flush
()
# Handle the response through the middleware
response
=
middleware
.
process_response
(
request
,
response
)
# Check that the cookie was deleted, not recreated.
# A deleted cookie header with a custom domain looks like:
# Set-Cookie: sessionid=; Domain=.example.local;
# expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
self
.
assertEqual
(
'Set-Cookie: {}={}; Domain=.example.local; expires=Thu, '
'01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/'
.
format
(
settings
.
SESSION_COOKIE_NAME
,
'""'
if
sys
.
version_info
>=
(
3
,
5
)
else
''
,
),
str
(
response
.
cookies
[
settings
.
SESSION_COOKIE_NAME
])
)
# Don't need DB flushing for these tests, so can use unittest.TestCase as base class
# Don't need DB flushing for these tests, so can use unittest.TestCase as base class
class
CookieSessionTests
(
SessionTestsMixin
,
unittest
.
TestCase
):
class
CookieSessionTests
(
SessionTestsMixin
,
unittest
.
TestCase
):
...
...
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