Add admin official account connection UI and persistent session secrets

This commit is contained in:
Pigway
2026-10-04 00:20:43 +08:00
parent 5aa0e9f762
commit b76af5ada3
12 changed files with 400 additions and 12 deletions
@@ -13,11 +13,19 @@ FrameDeviceDriver protocol does not depend on account login or widgets.
The public `/api/v1/devices/{device_id}/widgets` endpoint is unchanged. The old
`drivers.kokonna.widgets.WidgetReader` import remains a compatibility re-export.
No raw RPC proxy or public password-login endpoint is introduced. Future admin
account connection UI must use this module and keep credentials server-side.
No account or session secret is automatically persisted by this module.
No raw RPC proxy is exposed. The admin-only `/official/connection` endpoint
provides login (POST), state/discovery (GET), local frame association (PUT), and
local disconnect (DELETE), under `/api/v1/devices/{device_id}`. Browser requests
use the existing Frame Flow session and CSRF protection; API clients require admin.
`connection.py` persists the official session and selected robot in
`/config/official-{device_id}.secret`, atomically with mode 0600. Passwords are
transient and never stored. These files must not be committed or exposed to users.
Disconnect clears the local secret, including on restart; it does not revoke
remote official account sessions. Expired sessions require logging in again.
No login refresh or stored-password automatic retry is performed.
设备 API Key 仍负责现有设备、图片和图库接口。官方账号功能集中在本目录,
不进入 DisplayService、Renderer、Scheduler 或 FrameDeviceDriver。
账号登录已提供内部客户端能力;页面连接入口、写操作和会话持久化尚未实现。
账号连接页面与会话持久化已实现;额外写操作尚未实现。
所有已发现但未启用的 RPC 方法均拒绝执行,不复用 API Key 的写入开关。