feat: add multi-user RBAC with admin/viewer roles and user management
Some checks failed
CI / Check (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Formatting (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Release Build (push) Has been cancelled

Add complete multi-user support with role-based access control:

Backend:
- Add users CRUD endpoints (GET/POST/PUT/DELETE /api/users) with admin-only guards
- Add display_name column to users table with ALTER TABLE migration
- Fix auth to use session-based user identity (not hardcoded 'admin')
- Add POST /api/auth/logout to revoke server-side sessions
- Add require_admin() and extract_session() helpers for clean RBAC
- Guard all mutating endpoints (clients, providers, models, settings, backup)

Frontend:
- Add Users management page with create/edit/reset-password/delete modals
- Add role gating: hide edit/delete buttons for viewers on clients, providers, models
- Settings page hides auth tokens and admin actions for viewers
- Logout now revokes server session before clearing localStorage
- Sidebar shows real display_name and formatted role (Administrator/Viewer)
- Fix sidebar header: single logo with onerror fallback, renamed to 'LLM Proxy'
- Add badge and btn-action CSS classes for role pills and action buttons
- Bump cache-bust to v=7
This commit is contained in:
2026-03-02 15:58:33 -05:00
parent 5bf41be343
commit e07377adc0
17 changed files with 885 additions and 49 deletions

View File

@@ -840,6 +840,24 @@ body {
border: 1px solid var(--bg3);
}
/* Role / status badges */
.badge {
padding: 0.2rem 0.6rem;
border-radius: 9999px;
font-size: 0.7rem;
font-weight: 700;
text-transform: uppercase;
display: inline-flex;
align-items: center;
gap: 0.25rem;
letter-spacing: 0.03em;
}
.badge-success { background: rgba(184, 187, 38, 0.2); color: var(--green-light); }
.badge-info { background: rgba(69, 133, 136, 0.2); color: var(--blue-light); }
.badge-warning { background: rgba(250, 189, 47, 0.2); color: var(--yellow-light); }
.badge-danger { background: rgba(251, 73, 52, 0.2); color: var(--red-light); }
/* Charts */
.chart-container {
position: relative;
@@ -907,6 +925,37 @@ body {
.btn-danger { background: var(--red); color: var(--fg0); }
.btn-danger:hover { background: var(--red-light); }
/* Small inline action buttons (edit, delete, copy) */
.btn-action {
background: none;
border: 1px solid var(--bg3);
color: var(--fg3);
padding: 0.35rem 0.5rem;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s;
display: inline-flex;
align-items: center;
justify-content: center;
}
.btn-action:hover {
background: var(--bg2);
color: var(--fg0);
border-color: var(--bg4);
}
.btn-action.danger:hover {
background: rgba(251, 73, 52, 0.15);
color: var(--red-light);
border-color: var(--red);
}
.action-buttons {
display: flex;
gap: 0.5rem;
}
/* Modals */
.modal {
position: fixed;