chore(deps): auto fix by pre-commit hooks
This commit is contained in:
committed by
MingxuanGame
parent
b4fd4e0256
commit
7625cd99f5
14
app/auth.py
14
app/auth.py
@@ -154,21 +154,19 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None) -> s
|
||||
expire = utcnow() + expires_delta
|
||||
else:
|
||||
expire = utcnow() + timedelta(minutes=settings.access_token_expire_minutes)
|
||||
|
||||
|
||||
# 添加标准JWT声明
|
||||
to_encode.update({
|
||||
"exp": expire,
|
||||
"random": secrets.token_hex(16)
|
||||
})
|
||||
if hasattr(settings, 'jwt_audience') and settings.jwt_audience:
|
||||
to_encode.update({"exp": expire, "random": secrets.token_hex(16)})
|
||||
if hasattr(settings, "jwt_audience") and settings.jwt_audience:
|
||||
to_encode["aud"] = settings.jwt_audience
|
||||
if hasattr(settings, 'jwt_issuer') and settings.jwt_issuer:
|
||||
if hasattr(settings, "jwt_issuer") and settings.jwt_issuer:
|
||||
to_encode["iss"] = settings.jwt_issuer
|
||||
|
||||
|
||||
# 编码JWT
|
||||
encoded_jwt = jwt.encode(to_encode, settings.secret_key, algorithm=settings.algorithm)
|
||||
return encoded_jwt
|
||||
|
||||
|
||||
def generate_refresh_token() -> str:
|
||||
"""生成刷新令牌"""
|
||||
length = 64
|
||||
|
||||
Reference in New Issue
Block a user