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 1010import json
1111import os
1212import sys
13+ import time
1314import urllib .parse
1415from Cryptodome import Random
1516from Cryptodome .Cipher import AES
@@ -38,6 +39,7 @@ def configure():
3839
3940
4041def set_encrypted_oauth_cookie_on (response , cookiecontent , path = None ):
42+ cookiecontent ['_ts' ] = time .time ()
4143 cookiedata = json .dumps (cookiecontent )
4244 r = Random .new ()
4345 nonce = r .read (16 )
@@ -73,7 +75,13 @@ def get_encrypted_oauth_cookie(request):
7375 base64 .urlsafe_b64decode (parts ['t' ][0 ]),
7476 )
7577
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
7785
7886
7987def delete_encrypted_oauth_cookie_on (response ):
You can’t perform that action at this time.
0 commit comments