Appearance
文件:core/auth.py
负责 JWT 的生成与解析。
函数定义与行为
generate_token(request: Request, user_id: str, level: int) -> str
生成 JWT,载荷字段:
uid: 玩家 IDlvl: 可访问最大关卡等级fgp: 指纹 hash(由generate_fingerprint生成)iat: 签发时间戳exp: 过期时间戳
过期时间由 config/token_expire_hours 决定,签名算法 HS256。
decode_token(token: str) -> dict
使用 config/secret_key 解码 token,若过期或签名不匹配会抛出异常。