radio: refactor LRC fetching to directly use asyncio for backgrounding, and add null check for album art in RadioUtil
This commit is contained in:
19
utils/jwt_utils.py
Normal file
19
utils/jwt_utils.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from jose import jwt, JWTError
|
||||
from ..auth.key_store import get_key_by_kid
|
||||
|
||||
JWT_ALGORITHM = "HS256"
|
||||
|
||||
|
||||
def decode_jwt(token: str) -> dict | None:
|
||||
"""Decode a JWT token using the existing key management system."""
|
||||
try:
|
||||
headers = jwt.get_unverified_header(token)
|
||||
kid = headers.get("kid")
|
||||
if not kid:
|
||||
return None
|
||||
key = get_key_by_kid(kid)
|
||||
if not key:
|
||||
return None
|
||||
return jwt.decode(token, key, algorithms=[JWT_ALGORITHM])
|
||||
except JWTError:
|
||||
return None
|
Reference in New Issue
Block a user