file-store: don't response with cookies on file-store download.

This commit is contained in:
Marcin Kuzminski 2020-02-18 16:04:34 +01:00
parent e9a4bf30eb
commit ceaa1dd337
2 changed files with 9 additions and 2 deletions

View file

@ -93,6 +93,9 @@ class FileStoreView(BaseAppView):
file_path = self.storage.store_path(file_uid)
return FileResponse(file_path)
# For file store we don't submit any session data, this logic tells the
# Session lib to skip it
setattr(self.request, '_file_response', True)
@LoginRequired()
@NotAnonymous()

View file

@ -32,10 +32,14 @@ def BeakerSessionFactoryConfig(**options):
def session_callback(request, response):
exception = getattr(request, 'exception', None)
if (exception is None or self._cookie_on_exception) and self.accessed():
file_response = getattr(request, '_file_response', None)
if file_response is None \
and (exception is None or self._cookie_on_exception) \
and self.accessed():
self.persist()
headers = self.__dict__['_headers']
if headers['set_cookie'] and headers['cookie_out']:
if headers.get('set_cookie') and headers.get('cookie_out'):
response.headerlist.append(('Set-Cookie', headers['cookie_out']))
request.add_response_callback(session_callback)