Add SQLite storage and JWT auth with MFA/RBAC for the admin API - #123
Merged
Conversation
antoncxx
marked this pull request as ready for review
July 25, 2026 03:21
GyulyVGC
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
nullnet-serveradmin API and web UI had no authentication at all. This PR adds:diesel-async) as the foundation for everything below.admin/user) and per-user, per-resource scopes(
certificates,config,sessions,nodes,events— read/write where applicable).access-token refresh on the frontend.
What's included
Storage (
src/db/)users,user_scopes,refresh_tokens,login_attempts, alongsidethe pre-existing
certificates/dns_credentials/servicestables.diesel_migrationsinsidespawn_blocking.Auth core (
src/auth/)argon2password hashing,totp-rs-based TOTP (RFC 6238),jsonwebtoken(HS256) accesstokens (15 min TTL), opaque DB-revocable refresh tokens (SHA-256 hashed, 30-day TTL,
rotate-on-use).
MFA_ENCRYPTION_KEY) for TOTP secrets at rest — keptseparate from
CERT_ENCRYPTION_KEYso the two secret classes don't share blast radius.ADMIN_BOOTSTRAP_USERNAME/ADMIN_BOOTSTRAP_PASSWORD), a no-oponce any user exists; falls back to
admin/adminwith a loud startup warning if unset.the MFA-verify step of login.
HTTP API (
src/http_server/auth/)/api/auth/loginmfa_tokenif MFA is enabled/api/auth/mfa/verify/api/auth/refresh/api/auth/logout/api/auth/me/api/auth/mfa/setup|/confirm|/disable/api/auth/users[/{id}]Every pre-existing route (
certificates,config,sessions,nodes,events,graph,chains,stacks,services) now sits behindrequire_authmiddleware plus arequire_scopecheck matching its resource.
Frontend (
ui/)AuthContext,RequireAuth,apiFetch(auto-refresh-then-redirect on 401).Loginpage,Usersadmin page,MfaSetupDialog, and a first-everModalcomponent.flow.
Config
New required env vars (server refuses to start without
JWT_SIGNING_KEY/MFA_ENCRYPTION_KEY):See
README.mdfor the full rundown.