Skip to content

认证与健康检查

字数
307 字
阅读时间
2 分钟

基址:/pallas/api(下文路径均相对此前缀)。

公开 / 半公开

方法路径鉴权说明
GET/healthBot 与控制台版本、NoneBot 版本
POST/auth/loginBody {"password": "..."} → 设置会话 Cookie
GET/auth/setup-status返回是否仍处于默认密钥 / 首次引导阶段

需 token / 会话

方法路径说明
GET/systemCPU/内存/磁盘、运行时长等(短 TTL 缓存)
GET/bots已连接 Bot 实例列表(self_id、适配器、在线状态)

/health 响应要点

json
{
  "ok": true,
  "nonebot2": "2.x.x",
  "pallas_bot": "x.y.z",
  "console": { "version": "...", "build": "..." }
}

/system 响应

data 为系统资源快照;首页轮询约 5s,服务端有约 0.8s 读缓存。

/auth/setup-status 响应要点

json
{
  "ok": true,
  "data": {
    "auth_configured": true,
    "setup_completed": false,
    "default_password_active": true,
    "requires_setup": true
  }
}

含义:

  • default_password_active=true:仍在使用自动生成的默认密钥
  • requires_setup=true:前端应引导用户先改密,再继续其他配置

前端对应

  • fetchSystem()/system
  • http.get("/health")(健康探测)
  • 登录:POST /auth/login(SPA 登录页 GET /pallas/login

实现:api.py(health)、auth_security_api.py + system_home_api.py(system、bots、auth)、public.py(SPA 入口);由 extended_api.register_extended_api 编排。