mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-07 09:23:06 +02:00
refactor: companion FrameServer and related (substantive only, no Black)
Reapply refactor from ce8381a (replace monolithic FrameServer with thin pymc_core subclass, re-export constants, SQLite persistence hooks) while preserving pre-refactor whitespace where patch applied cleanly. Remaining files match refactor commit exactly. Diff vs ce8381a is whitespace-only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import jwt
|
||||
import logging
|
||||
import time
|
||||
from typing import Dict, Optional
|
||||
import logging
|
||||
|
||||
import jwt
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class JWTHandler:
|
||||
def __init__(self, secret: str, expiry_minutes: int = 15):
|
||||
self.secret = secret
|
||||
@@ -14,21 +16,16 @@ class JWTHandler:
|
||||
|
||||
now = int(time.time())
|
||||
expiry = now + (self.expiry_minutes * 60)
|
||||
|
||||
payload = {
|
||||
'sub': username,
|
||||
'exp': expiry,
|
||||
'iat': now,
|
||||
'client_id': client_id
|
||||
}
|
||||
|
||||
token = jwt.encode(payload, self.secret, algorithm='HS256')
|
||||
|
||||
payload = {"sub": username, "exp": expiry, "iat": now, "client_id": client_id}
|
||||
|
||||
token = jwt.encode(payload, self.secret, algorithm="HS256")
|
||||
logger.info(f"Created JWT for user '{username}' with client_id '{client_id[:8]}...'")
|
||||
return token
|
||||
|
||||
|
||||
def verify_jwt(self, token: str) -> Optional[Dict]:
|
||||
try:
|
||||
payload = jwt.decode(token, self.secret, algorithms=['HS256'])
|
||||
payload = jwt.decode(token, self.secret, algorithms=["HS256"])
|
||||
return payload
|
||||
except jwt.ExpiredSignatureError:
|
||||
logger.warning("JWT token expired")
|
||||
|
||||
Reference in New Issue
Block a user