Add 2 day TTL to page tokens
This commit is contained in:
parent
b4bddacedb
commit
335c8eb3a9
3 changed files with 9 additions and 6 deletions
|
@ -7,11 +7,11 @@ def encrypt_string(string, key):
|
|||
f = Fernet(base64.urlsafe_b64encode(key))
|
||||
return f.encrypt(string)
|
||||
|
||||
def decrypt_string(string, key):
|
||||
def decrypt_string(string, key, ttl=None):
|
||||
""" Decrypts an encrypted string with the specified key. The key must be 32 raw bytes. """
|
||||
f = Fernet(base64.urlsafe_b64encode(key))
|
||||
try:
|
||||
return f.decrypt(string)
|
||||
return f.decrypt(string, ttl=ttl)
|
||||
except InvalidToken:
|
||||
return None
|
||||
except TypeError:
|
||||
|
|
Reference in a new issue