File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 10
10
import json
11
11
import os
12
12
import sys
13
+ import time
13
14
import urllib .parse
14
15
from Cryptodome import Random
15
16
from Cryptodome .Cipher import AES
@@ -38,6 +39,7 @@ def configure():
38
39
39
40
40
41
def set_encrypted_oauth_cookie_on (response , cookiecontent , path = None ):
42
+ cookiecontent ['_ts' ] = time .time ()
41
43
cookiedata = json .dumps (cookiecontent )
42
44
r = Random .new ()
43
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
)
75
77
76
- 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
77
85
78
86
79
87
def delete_encrypted_oauth_cookie_on (response ):
You can’t perform that action at this time.
0 commit comments