* feat(web): multi-user accounts with fixed admin/operator/viewer roles - migration 6 adds web_users and copies the existing single admin with the same id and password hash, so upgrades need no action and existing sessions stay logged in - table-driven permission middleware on every business route (default deny), 403 for missing permission, 401 when logged out - hooks/override and secrets redacted for non-admins; operators may only pick registered bilibili accounts for templates - /v1/web-users management API, /v1/me and self password change - login rate limit: 5 consecutive failures lock the username for 30s - revoked sessions cut long-lived websocket/stream responses Refs #1717 * feat(cli): add `biliup user list` and `biliup user reset-password` Refs #1717 * feat(web-ui): user management page, account menu and editable login name - /users page (super admin only): create users, change role, reset password, disable, force logout, delete; table on desktop, cards on mobile, with loading/empty/error states - sidebar filters menu entries by the permissions from /v1/me and shows a no-access state for pages the role cannot open - account menu in the sidebar footer with change password and logout, hidden when --auth is off - 403 responses show a warning toast instead of redirecting - login page username is editable (default biliup) Refs #1717 * feat(web-ui): hide actions the current role cannot perform Streamer add/edit/delete/pause, hook and override editing, template and upload actions, bilibili account management and config saving are only rendered for roles that have the matching permission. Account and type tree requests are skipped for roles that would get 403. Refs #1717 * fix(web-ui): wait for permissions on restricted pages, surface pause errors - pages that need a permission not every role has render a spinner until /v1/me returns, so roles without it never fire requests doomed to 403 - user management is hidden when --auth is off, with an explanation if the page is opened directly - the pause button goes through the shared response handler, so a 403 shows the permission toast instead of failing silently - permission errors sent as plain text keep their message Refs #1717 * fix(web-ui): keep user actions reachable on tablet and narrow desktop Refs #1717 * fix(py): handle the user subcommand in the stream-gears entry point Refs #1717
23 lines
1.0 KiB
SQL
23 lines
1.0 KiB
SQL
-- Web 用户与固定三角色(#1717)。
|
|
--
|
|
-- 老的单管理员原样迁过来:沿用 configuration 里的 id 与密码哈希,这样升级后
|
|
-- 会话里存的 user id 与 auth hash 都不变,已登录的浏览器不会掉线。
|
|
-- configuration 里 key = 'biliup' 那一行保留不删:回退到旧版本时仍能用原密码登录,
|
|
-- 新代码不再读写它。
|
|
CREATE TABLE web_users (
|
|
id INTEGER PRIMARY KEY,
|
|
username TEXT NOT NULL COLLATE NOCASE UNIQUE,
|
|
password_hash TEXT NOT NULL,
|
|
role TEXT NOT NULL CHECK (role IN ('admin', 'operator', 'viewer')),
|
|
disabled INTEGER NOT NULL DEFAULT 0 CHECK (disabled IN (0, 1)),
|
|
session_version INTEGER NOT NULL DEFAULT 0,
|
|
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
updated_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
last_login_at INTEGER
|
|
);
|
|
|
|
INSERT INTO web_users (id, username, password_hash, role)
|
|
SELECT id, 'biliup', value, 'admin'
|
|
FROM configuration
|
|
WHERE key = 'biliup';
|