mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
remove legacy jwt encoding module
This commit is contained in:
parent
dfca1a5bc1
commit
16e9dc82fa
1 changed files with 0 additions and 26 deletions
|
|
@ -1,26 +0,0 @@
|
|||
"""Handle JSON Web Token Encoding & Decoding."""
|
||||
|
||||
# Standard Library
|
||||
import datetime
|
||||
|
||||
# Third Party
|
||||
import jwt
|
||||
|
||||
|
||||
async def jwt_decode(payload: str, secret: str) -> str:
|
||||
"""Decode & validate an encoded JSON Web Token (JWT)."""
|
||||
decoded = jwt.decode(payload, secret, algorithm="HS256")
|
||||
decoded = decoded["payload"]
|
||||
return decoded
|
||||
|
||||
|
||||
async def jwt_encode(payload: str, secret: str, duration: int) -> str:
|
||||
"""Encode a query to a JSON Web Token (JWT)."""
|
||||
token = {
|
||||
"payload": payload,
|
||||
"nbf": datetime.datetime.utcnow(),
|
||||
"iat": datetime.datetime.utcnow(),
|
||||
"exp": datetime.datetime.utcnow() + datetime.timedelta(seconds=duration),
|
||||
}
|
||||
encoded = jwt.encode(token, secret, algorithm="HS256").decode("utf-8")
|
||||
return encoded
|
||||
Loading…
Add table
Reference in a new issue