feat(admin): 从管理端免登打开 Dify 控制台
工作人员经一次性跳转进入本地 Dify。AI 智能体菜单去掉已停用项,文件页工具栏收进表头,并关闭快速入口。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d96f7a2238
commit
60158935f4
14 files changed
+521
-53
No files matched your search
@@ -0,0 +1,32 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.deps import require_staff
|
||||
from app.db import get_db
|
||||
from app.services import dify_sso as dify_sso_service
|
||||
|
||||
router = APIRouter(dependencies=[Depends(require_staff)])
|
||||
|
||||
|
||||
class SsoOpenIn(BaseModel):
|
||||
nextPath: str | None = Field(default="/apps", description="Dify console path after login")
|
||||
|
||||
|
||||
def _actor_id(principal: dict = Depends(require_staff)) -> int:
|
||||
try:
|
||||
return int(principal["sub"])
|
||||
except (TypeError, ValueError):
|
||||
from fastapi import HTTPException
|
||||
|
||||
raise HTTPException(status_code=401, detail="登录已失效")
|
||||
|
||||
|
||||
@router.post("/dify/sso")
|
||||
def open_dify_sso(
|
||||
body: SsoOpenIn,
|
||||
actor_id: int = Depends(_actor_id),
|
||||
db: Session = Depends(get_db),
|
||||
) -> dict:
|
||||
"""Issue a one-shot redirect URL that logs the current staff into Dify."""
|
||||
return dify_sso_service.issue_redirect(db, user_id=actor_id, next_path=body.nextPath)
|
||||
Reference in new issue
Block a user