1
0
mirror of https://github.com/quay/quay.git synced 2025-04-18 10:44:06 +03:00
quay/util/pagination.py
Kenny Lee Sin Cheong 5f63b3a7bb
chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00

27 lines
657 B
Python

import datetime
import json
from app import app
from util.security.crypto import decrypt_string, encrypt_string
# TTL (in seconds) for page tokens.
_PAGE_TOKEN_TTL = datetime.timedelta(days=2).total_seconds()
def decrypt_page_token(token_string):
if token_string is None:
return None
unencrypted = decrypt_string(token_string, app.config["PAGE_TOKEN_KEY"], ttl=_PAGE_TOKEN_TTL)
if unencrypted is None:
return None
try:
return json.loads(unencrypted)
except ValueError:
return None
def encrypt_page_token(page_token):
return encrypt_string(json.dumps(page_token), app.config["PAGE_TOKEN_KEY"])