Skip to content

Commit aff5175

Browse files
committed
Remove token last used field in the token store
This would be a nice feature to have, but it can lead lead to (very rare) race conditions. simplekv has no way to support atomic retreive and replace. We could revoke a key after grabbing the key to update, then overwrite the revoke status. This also makes storing an effecient mapping of jtis that exist to an identity hard. Currently, I'm thinking if a user wants this, they should add it as part of their application logic, something like @app.route('foobar') @jwt_refresh_token_required def refresh: udate_token_last_used(jti) # Need a way for users to get the jti access_token = create_access_token() return ...
1 parent a22114d commit aff5175

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

flask_jwt_extended/blacklist.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ def wrapper(*args, **kwargs):
3434
return wrapper
3535

3636

37-
def _utc_datetime_to_ts(dt):
38-
return calendar.timegm(dt.utctimetuple())
39-
40-
4137
def _ts_to_utc_datetime(ts):
4238
return datetime.datetime.utcfromtimestamp(ts)
4339

@@ -159,7 +155,6 @@ def store_token(token, revoked):
159155
"""
160156
data_to_store = json.dumps({
161157
'token': token,
162-
'last_used': _utc_datetime_to_ts(datetime.datetime.utcnow()),
163158
'revoked': revoked
164159
}).encode('utf-8')
165160

tests/test_blacklist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def test_get_stored_token(self):
378378
self.assertEqual(status_code, 200)
379379
self.assertIn('token', data)
380380
self.assertIn('revoked', data)
381-
self.assertIn('last_used', data)
381+
self.assertEqual(len(data), 2)
382382

383383
response = self.client.get('/auth/token/404notokenfound')
384384
status_code = response.status_code

0 commit comments

Comments
 (0)