feat: 用安装页和编排完成部署,并整理登录页
This commit is contained in:
+14
-1
@@ -8,7 +8,7 @@ import os
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
from app.config import jwt_secret
|
||||
from app.config import installed
|
||||
|
||||
ITERATIONS = 200_000
|
||||
TOKEN_TTL = 12 * 60 * 60
|
||||
@@ -36,6 +36,19 @@ def _decode(raw: str) -> dict[str, Any]:
|
||||
return json.loads(base64.urlsafe_b64decode(padded.encode("ascii")))
|
||||
|
||||
|
||||
def jwt_secret() -> str:
|
||||
if not installed():
|
||||
raise RuntimeError("尚未安装")
|
||||
from app.db import session_scope
|
||||
from app.models import AppSetting
|
||||
|
||||
with session_scope() as session:
|
||||
setting = session.get(AppSetting, 1)
|
||||
if setting is None or not setting.jwt_secret:
|
||||
raise RuntimeError("尚未安装")
|
||||
return setting.jwt_secret
|
||||
|
||||
|
||||
def issue_token(payload: dict[str, Any]) -> str:
|
||||
body = {**payload, "exp": int(time.time()) + TOKEN_TTL}
|
||||
raw = _encode(body)
|
||||
|
||||
Reference in New Issue
Block a user