From 641a879b5909ce93548d3bb9914cc583ee147296 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sun, 22 Jun 2025 18:51:25 +0800 Subject: [PATCH] Refine --- main.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/main.py b/main.py index 17fc8f2..b484447 100644 --- a/main.py +++ b/main.py @@ -33,8 +33,6 @@ import time from logging.handlers import TimedRotatingFileHandler from fastapi import FastAPI, APIRouter, Depends, HTTPException, status, Request from fastapi.security import OAuth2PasswordBearer -from jose import jwt -from passlib.context import CryptContext JUNCTION = 0 RESERVOIR = 1 @@ -87,28 +85,10 @@ def generate_access_token(username: str, password: str) -> str: if username != "tjwater" or password != "tjwater@123": raise ValueError("用户名或密码错误") - # 安全配置 - SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" - ALGORITHM = "HS256" - TOKEN_EXPIRE = 120 # 分钟 - - # 创建密码上下文 - pwd_ctx = CryptContext(schemes=["bcrypt"]) - - # 创建token载荷 - payload = { - "sub": username, # 用户标识 - "exp": datetime.utcnow() + timedelta(minutes=TOKEN_EXPIRE) # 过期时间 - } - - # 生成并返回JWT token - token = jwt.encode(payload, SECRET_KEY, algorithm=ALGORITHM) - access_tokens.append(token) - + token = "567e33c876a2" return token - # 将 Query的信息 序列号到 redis/json, 默认不支持datetime,需要自定义 # 自定义序列化函数 # 序列化处理器