feat: multi-user authentication with role-based access control - #797
feat: multi-user authentication with role-based access control#797Schattenwelt wants to merge 20 commits into
Conversation
35403f3 to
c14b21c
Compare
- Update-Channel in service.go now points to Schattenwelt/NanoKVM Releases - Fix dangling reference: hid.go re-adds HIDLoopbackHTTPAllowedPaths that router.go was already calling (broken build on fresh clone) - Add cgo build tag + kvm_vision_stub.go for non-CGO builds - network.go: re-add RequireRole(Admin, Operator) on Wake-on-LAN endpoint - http.ts: re-add PUT method used by user-management UI - Various source-formatting alignments to match the released binary
|
Will this eventually get released for the NANOKVMPRO? |
|
There are no current plans for that, and I don't have a NANOKVMPRO to test either. |
Its not released for the NANOKVM either yet, right? We've tried them all. The KVMPRO is amazing using PIKVM for user accounts to give customers, but it would be nice to have a GUI based user creation rather than having to use terminal for it. |
84da9ec to
40bbeab
Compare
|
@Schattenwelt Hi, I noticed this PR was closed, but I’m not sure why. The contribution looks great, so I wanted to ask if there was any reason behind the decision. Could you please share some context? If there are any issues that need to be addressed, we’d be happy to help discuss possible improvements. Thanks! |
|
Hi @SiYue-ZO, thanks for reaching out — much appreciated! The PR was closed by mistake and is open again now. I've used the chance to clean it up: it's now scoped down to just the multi-user auth + RBAC feature (from 74 files to 41), rebased onto current Both the Go backend and the TypeScript frontend build cleanly locally against the latest The other features that were previously mixed in (audit logging, static IPv4, PicoClaw hardening, USB MAC determinism) will follow as separate focused PRs. Happy to adjust anything you'd suggest — thanks for taking a look! |
# Conflicts: # CHANGELOG.md # README.md # server/router/hid.go # server/router/vm.go # web/src/pages/desktop/menu/index.tsx # web/src/pages/desktop/menu/settings/index.tsx
73efd88 to
6494558
Compare
Multi-User Authentication with Role-Based Access Control
Summary
This PR adds support for multiple users with three distinct roles, replacing the current single-user authentication system.
Motivation
Many users (myself included) want to give different people different levels of access to the NanoKVM:
Currently only one shared admin account exists, which is a security and usability limitation.
Roles
adminoperatorviewerChanges
Backend (Go)
server/service/auth/account.go– New multi-user storage in/etc/kvm/accounts.json(bcrypt hashed)server/service/auth/login.go– Role embedded in JWT claimsserver/service/auth/password.go– Permission-aware password changesserver/service/auth/users.go– NEW – CRUD endpoints for user managementserver/middleware/jwt.go– NewRequireRole()middleware for fine-grained access controlserver/proto/auth.go– New request/response typesserver/router/auth.go– New user management endpointsserver/router/hid.go– Role-based access (operator+ for inputs)server/router/vm.go– Role-based access per endpointFrontend (React)
web/src/hooks/useRole.ts– NEW – Hook to retrieve current user roleweb/src/pages/desktop/menu/settings/users/index.tsx– NEW – User management UIweb/src/pages/desktop/menu/settings/index.tsx– Tabs filtered by roleweb/src/pages/desktop/menu/index.tsx– Menu items hidden based on roleweb/src/api/auth.ts– New API functions for user managementweb/src/i18n/locales/{all}.ts– TranslationsBackwards compatibility
The legacy
/etc/kvm/pwdfile is automatically migrated to/etc/kvm/accounts.jsonon first start. The migrated user receives theadminrole.New API Endpoints
All require
adminrole except/api/auth/users/:username/password(admins can change anyone's password, others only their own).Testing
Tested on NanoKVM-PCIe with NanoKVM v2.4.3:
Screenshot
(add a screenshot of the user management page here)
