Team Ai
Apppublic

deepak2563/opensourcetranscriptmaker

sourceHugging Faceunknownupdated 4mo agoView on Hugging Face
0likes
access_control.py26 linesDownload Raw Back to services
1import os2import jwt3from datetime import datetime, timedelta, timezone4 5# Use a default secret for development if not provided6JWT_SECRET = os.environ.get("JWT_SECRET", "super-secret-dev-key")7JWT_ALGORITHM = "HS256"8SESSION_EXPIRE_MINUTES = 60 * 24 # 24 hours9 10def verify_password(password: str) -> bool:11    shared_password = os.environ.get("SHARED_APP_PASSWORD", "devpassword")12    return password == shared_password13 14def create_access_token() -> str:15    expire = datetime.now(timezone.utc) + timedelta(minutes=SESSION_EXPIRE_MINUTES)16    to_encode = {"exp": expire, "sub": "unlocked_user"}17    encoded_jwt = jwt.encode(to_encode, JWT_SECRET, algorithm=JWT_ALGORITHM)18    return encoded_jwt19 20def verify_access_token(token: str) -> bool:21    try:22        jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGORITHM])23        return True24    except jwt.PyJWTError:25        return False26