comparison roundup/cgi/templating.py @ 5211:f4b6a2a3e605

Fix expiration dates and expire csrf tokens properly In client.py: add explicit expiration of csrf tokens to handle_csrf. There is a clean_up() that runs on every client connection before handle)csrf is invoked, but it only cleans every hour. With short lived tokens this is insufficient. Also remove debugging. In templating.py fix values for seconds/week and minutes per week. The original values were shifted/transposed and an order of magnitude off. In test_templating.py again fix seconds/week constant.
author John Rouillard <rouilj@ieee.org>
date Sun, 19 Mar 2017 17:10:13 -0400
parents 47bd81998ddc
children 17b213eab274
comparison
equal deleted inserted replaced
5210:7da56980754d 5211:f4b6a2a3e605
95 # offset to time.time is calculated as: 95 # offset to time.time is calculated as:
96 # default lifetime is 1 week after __timestamp. 96 # default lifetime is 1 week after __timestamp.
97 # That's the cleanup period hardcoded in otk.clean(). 97 # That's the cleanup period hardcoded in otk.clean().
98 # If a user wants a 10 minute lifetime calculate 98 # If a user wants a 10 minute lifetime calculate
99 # 10 minutes newer than 1 week ago. 99 # 10 minutes newer than 1 week ago.
100 # lifetime - 10800 (number of minutes in a week) 100 # lifetime - 10080 (number of minutes in a week)
101 # convert to seconds and add (possible negative number) 101 # convert to seconds and add (possible negative number)
102 # from time.time(). 102 # to current time (time.time()).
103 ts = time.time() + ((lifetime - 10080) * 60)
103 otks.set(key, uid=client.db.getuid(), 104 otks.set(key, uid=client.db.getuid(),
104 sid=client.session_api._sid, 105 sid=client.session_api._sid,
105 __timestamp=time.time() + ((lifetime - 10800) * 60) ) 106 __timestamp=ts )
106 client.db.commit() 107 client.db.commit()
107 return key 108 return key
108 109
109 ### templating 110 ### templating
110 111

Roundup Issue Tracker: http://roundup-tracker.org/