Add HTTP_AUTHORIZATION to values copied to dummy preview requests

pull/4773/merge
Ben Dickinson 2018-09-11 23:01:07 +01:00 zatwierdzone przez Matt Westcott
rodzic 8ef0edb371
commit 4c72f767ea
5 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ Changelog
* Notification emails now include an "Auto-Submitted: auto-generated" header (Dan Braghis) * Notification emails now include an "Auto-Submitted: auto-generated" header (Dan Braghis)
* Image chooser panels now show alt text as title (Samir Shah) * Image chooser panels now show alt text as title (Samir Shah)
* Added `download_url` field to images in the API (Michael Harrison) * Added `download_url` field to images in the API (Michael Harrison)
* Dummy requests for preview now preserve the HTTP Authorization header (Ben Dickinson)
* Fix: Respect next param on login (Loic Teixeira) * Fix: Respect next param on login (Loic Teixeira)
* Fix: InlinePanel now handles relations that specify a related_query_name (Aram Dulyan) * Fix: InlinePanel now handles relations that specify a related_query_name (Aram Dulyan)
* Fix: before_delete_page / after_delete_page hooks now run within the same database transaction as the page deletion (Tomasz Knapik) * Fix: before_delete_page / after_delete_page hooks now run within the same database transaction as the page deletion (Tomasz Knapik)

Wyświetl plik

@ -316,6 +316,7 @@ Contributors
* Matthew Schinckel * Matthew Schinckel
* Michael Borisov * Michael Borisov
* Dan Braghis * Dan Braghis
* Ben Dickinson
Translators Translators
=========== ===========

Wyświetl plik

@ -29,6 +29,7 @@ Other features
* Notification emails now include an "Auto-Submitted: auto-generated" header (Dan Braghis) * Notification emails now include an "Auto-Submitted: auto-generated" header (Dan Braghis)
* Image chooser panels now show alt text as title (Samir Shah) * Image chooser panels now show alt text as title (Samir Shah)
* Added ``download_url`` field to images in the API (Michael Harrison) * Added ``download_url`` field to images in the API (Michael Harrison)
* Dummy requests for preview now preserve the HTTP Authorization header (Ben Dickinson)
Bug fixes Bug fixes

Wyświetl plik

@ -1242,7 +1242,7 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
# Add important values from the original request object, if it was provided. # Add important values from the original request object, if it was provided.
HEADERS_FROM_ORIGINAL_REQUEST = [ HEADERS_FROM_ORIGINAL_REQUEST = [
'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'HTTP_COOKIE', 'HTTP_USER_AGENT', 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'HTTP_COOKIE', 'HTTP_USER_AGENT', 'HTTP_AUTHORIZATION',
'wsgi.version', 'wsgi.multithread', 'wsgi.multiprocess', 'wsgi.run_once', 'wsgi.version', 'wsgi.multithread', 'wsgi.multiprocess', 'wsgi.run_once',
] ]
if settings.SECURE_PROXY_SSL_HEADER: if settings.SECURE_PROXY_SSL_HEADER:

Wyświetl plik

@ -1371,6 +1371,7 @@ class TestDummyRequest(TestCase):
'HTTP_X_FORWARDED_FOR': '192.168.0.2,192.168.0.3', 'HTTP_X_FORWARDED_FOR': '192.168.0.2,192.168.0.3',
'HTTP_COOKIE': "test=1;blah=2", 'HTTP_COOKIE': "test=1;blah=2",
'HTTP_USER_AGENT': "Test Agent", 'HTTP_USER_AGENT': "Test Agent",
'HTTP_AUTHORIZATION': "Basic V2FndGFpbDpXYWd0YWlsCg==",
} }
factory = RequestFactory(**original_headers) factory = RequestFactory(**original_headers)
original_request = factory.get('/home/events/') original_request = factory.get('/home/events/')
@ -1381,6 +1382,7 @@ class TestDummyRequest(TestCase):
self.assertEqual(request.META['HTTP_X_FORWARDED_FOR'], original_request.META['HTTP_X_FORWARDED_FOR']) self.assertEqual(request.META['HTTP_X_FORWARDED_FOR'], original_request.META['HTTP_X_FORWARDED_FOR'])
self.assertEqual(request.META['HTTP_COOKIE'], original_request.META['HTTP_COOKIE']) self.assertEqual(request.META['HTTP_COOKIE'], original_request.META['HTTP_COOKIE'])
self.assertEqual(request.META['HTTP_USER_AGENT'], original_request.META['HTTP_USER_AGENT']) self.assertEqual(request.META['HTTP_USER_AGENT'], original_request.META['HTTP_USER_AGENT'])
self.assertEqual(request.META['HTTP_AUTHORIZATION'], original_request.META['HTTP_AUTHORIZATION'])
# check other env vars required by the WSGI spec # check other env vars required by the WSGI spec
self.assertEqual(request.META['REQUEST_METHOD'], 'GET') self.assertEqual(request.META['REQUEST_METHOD'], 'GET')