mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 20:05:03 -02:30
stop various async background requests from bumping the session expiry
if a user has an active session that just sits on the dashboard or job list, websocket messages that come in (for e.g., job status changes) will trigger AJAX requests for more data; this process causes a user with an idle login to continue to generate API requests, which in turn ticks their expiry timer. As a result, users with active sessions sitting on these two (popular) pages will never be automatically logged out via SESSION_MAX_AGE. this change introduces a special header that the UI can use to signify that a request shouldn't bump the expiry timer
This commit is contained in:
@@ -126,8 +126,9 @@ class SessionTimeoutMiddleware(object):
|
||||
"""
|
||||
|
||||
def process_response(self, request, response):
|
||||
should_skip = 'HTTP_X_WS_SESSION_QUIET' in request.META
|
||||
req_session = getattr(request, 'session', None)
|
||||
if req_session and not req_session.is_empty():
|
||||
if req_session and not req_session.is_empty() and should_skip is False:
|
||||
expiry = int(settings.SESSION_COOKIE_AGE)
|
||||
request.session.set_expiry(expiry)
|
||||
response['Session-Timeout'] = expiry
|
||||
|
||||
Reference in New Issue
Block a user