We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb629db commit 252c238Copy full SHA for 252c238
1 file changed
pgweb/account/oauthclient.py
@@ -10,6 +10,7 @@
10
import json
11
import os
12
import sys
13
+import time
14
import urllib.parse
15
from Cryptodome import Random
16
from Cryptodome.Cipher import AES
@@ -38,6 +39,7 @@ def configure():
38
39
40
41
def set_encrypted_oauth_cookie_on(response, cookiecontent, path=None):
42
+ cookiecontent['_ts'] = time.time()
43
cookiedata = json.dumps(cookiecontent)
44
r = Random.new()
45
nonce = r.read(16)
@@ -73,7 +75,13 @@ def get_encrypted_oauth_cookie(request):
73
75
base64.urlsafe_b64decode(parts['t'][0]),
74
76
)
77
- return json.loads(s)
78
+ d = json.loads(s)
79
+ if time.time() - d['_ts'] > 10 * 60:
80
+ # 10 minutes to complete oauth login
81
+ raise OAuthException("Cookie expired")
82
+ del d['_ts']
83
+
84
+ return d
85
86
87
def delete_encrypted_oauth_cookie_on(response):
0 commit comments