Make cookie a string

This commit is contained in:
Quantum 2023-12-21 03:25:50 -05:00
parent ae6fd65981
commit 2769dfd5f8

View file

@ -56,10 +56,10 @@ class Context:
return ''.join([self.ldap_group]).encode('utf-8')
def make_cookie(context: Context) -> bytes:
def make_cookie(context: Context) -> str:
message = timestamp.pack(int(time.time()) + DURATION) + os.urandom(RANDOM_SIZE) + context.bytes()
signature = hmac.new(HMAC_KEY, message, hmac_digest).digest()
return base64.b64encode(signature + message)
return base64.b64encode(signature + message).decode()
def verify_cookie(cookie: Optional[str], context: Context) -> bool: