test/custom-admin-ui #3

Merged
orion merged 673 commits from test/custom-admin-ui into master 2026-06-05 17:20:58 +08:00
3 changed files with 4 additions and 3 deletions
Showing only changes of commit f72e121406 - Show all commits
+1 -1
View File
@@ -47,4 +47,4 @@ async def get_code(s: AsyncSession):
async def get_token(ip, code): async def get_token(ip, code):
return hashlib.sha256(f"{ip}{code}{int(time.time()) / 1000}000{settings.SECRET_KEY}".encode()).hexdigest() return hashlib.sha256(f"{ip}{code}{int(time.time() / 1000)}000{settings.ADMIN_PASSWORD}".encode()).hexdigest()
+2 -2
View File
@@ -130,7 +130,7 @@ async def index(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession =
await s.execute(update(Codes).where(Codes.id == info.id).values(count=info.count - 1)) await s.execute(update(Codes).where(Codes.id == info.id).values(count=info.count - 1))
await s.commit() await s.commit()
if info.type != 'text': if info.type != 'text':
info.text = f'/select?code={info.code}&token={get_token(code, ip)}' info.text = f'/select?code={info.code}&token={await get_token(code, ip)}'
return { return {
'detail': f'取件成功,请立即下载,避免失效!', 'detail': f'取件成功,请立即下载,避免失效!',
'data': {'type': info.type, 'text': info.text, 'name': info.name, 'code': info.code} 'data': {'type': info.type, 'text': info.text, 'name': info.name, 'code': info.code}
@@ -150,7 +150,7 @@ async def banner(request: Request):
@app.get('/select') @app.get('/select')
async def get_file(code: str, token: str, ip: str = Depends(error_ip_limit), s: AsyncSession = Depends(get_session)): async def get_file(code: str, token: str, ip: str = Depends(error_ip_limit), s: AsyncSession = Depends(get_session)):
# 验证token # 验证token
if token != get_token(code, ip): if token != await get_token(code, ip):
error_ip_limit.add_ip(ip) error_ip_limit.add_ip(ip)
raise HTTPException(status_code=403, detail="口令错误,或已过期,次数过多将被禁止访问") raise HTTPException(status_code=403, detail="口令错误,或已过期,次数过多将被禁止访问")
# 查出数据库记录 # 查出数据库记录
+1
View File
@@ -1,6 +1,7 @@
import uuid import uuid
from starlette.config import Config from starlette.config import Config
import configparser
# 配置文件.env,存放为data/.env # 配置文件.env,存放为data/.env
config = Config("data/.env") config = Config("data/.env")