Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout inactive is improperly used #55

Open
mchouque opened this issue Jul 27, 2022 · 0 comments
Open

Timeout inactive is improperly used #55

mchouque opened this issue Jul 27, 2022 · 0 comments

Comments

@mchouque
Copy link

mchouque commented Jul 27, 2022

Hello,

# 15 seconds is the default keep alive timeout
self.inactive_expiration = now + 15

The issue is when you query the session endpoint, what it returns is:

{"services":["platform"],"timeout_absolute":14400,"timeout_inactive":900,"username":"someuser"}

Timeout inactive is not 15 seconds it's 15 minutes... So not only the code is wrong but it should really do something like:

--- api_client.py.orig  2022-07-27 11:03:58.739454831 +0200
+++ api_client.py       2022-07-27 11:45:37.025356419 +0200
@@ -83,6 +83,7 @@
 
         self.session_expiration = 0
         self.inactive_expiration = 0
+        self.inactive_threshold = 0
         self.x_csrf_token = None
 
     def __del__(self):
@@ -548,6 +548,7 @@
                 self.cookie = cookies.split(';')[0]
                 timeout = json.loads(response_data.data)['timeout_absolute']
                 self.session_expiration = now + timeout
+                self.inactive_threshold = json.loads(response_data.data)['timeout_inactive']
 
                 try:
                     # extract X-CSRF token from response cookies
@@ -557,8 +565,8 @@
                     # this is not an anti-CSRF version of PAPI
                     pass
 
-        # 15 seconds is the default keep alive timeout
-        self.inactive_expiration = now + 15
+        # Increase inactive_expiration by inactive_threshold
+        self.inactive_expiration = now + max(self.inactive_threshold, 15)
 
         headers['Cookie'] = self.cookie
         if self.x_csrf_token:

Regards,
Mathieu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant