feat: Add a verification interface for the assistant

This commit is contained in:
fit2cloud-chenyw
2026-07-29 11:27:21 +08:00
committed by fit2cloud-chenyw
parent 016b803a55
commit 4058ad3602
2 changed files with 21 additions and 1 deletions
+20
View File
@@ -221,6 +221,26 @@ async def ui(session: SessionDep, data: str = Form(), files: List[UploadFile] =
async def clear_ui_cache(id: int):
pass
@router.get("/validate/{id}", include_in_schema=False)
async def validate(request: Request, response: Response, session: SessionDep, trans: Trans, id: int):
if not id:
raise Exception('miss assistant id')
db_model = session.get(AssistantModel, id)
if not db_model:
raise RuntimeError(f"assistant application not exist")
origin = request.headers.get("origin") or get_origin_from_referer(request)
if not origin:
raise RuntimeError(trans('i18n_embedded.invalid_origin', origin=origin or ''))
origin = origin.rstrip('/')
if not origin_match_domain(origin, db_model.domain):
raise RuntimeError(trans('i18n_embedded.invalid_origin', origin=origin or ''))
response.headers["Access-Control-Allow-Origin"] = origin
return {"valid": True, "origin": origin}
@router.get("/ds", include_in_schema=False, response_model=list[dict])
async def ds(session: SessionDep, current_assistant: CurrentAssistant):
if current_assistant.type == 0:
+1 -1
View File
@@ -29,10 +29,10 @@ wlist = [
"/sse",
"/system/appearance/ui",
"/system/appearance/picture/*",
"/system/assistant/validator*",
"/system/assistant/info/*",
"/system/assistant/app/*",
"/system/assistant/picture/*",
"/system/assistant/validate/*",
"/system/authentication/platform/status",
"/system/authentication/login/*",
"/system/authentication/sso/*",