2.8 KiB
Authentication
The current server has a starter authentication layer:
- persistent local users in a JSON file
- form login at
/login - logout at
/logout - HTTP-only session cookie
- protected dashboard, API, and printer proxy routes
- self-service account page at
/account - admin audit trail at
/audit - admin-only user management at
/users - per-user printer grants with read or control access
For local development, Docker Compose uses:
username: admin
password: admin
Run the server with different credentials:
$env:KA_AGENT_TOKEN = "replace-agent-token"
$env:KA_ADMIN_USER = "your-user"
$env:KA_ADMIN_PASSWORD = "your-password"
klipperanywhere-server -listen :8080
When serving over HTTPS, enable secure cookies:
$env:KA_COOKIE_SECURE = "true"
klipperanywhere-server -listen :8080
CLI flags still exist for local overrides, but environment variables are preferred for secrets.
The users file defaults to data/users.json in the server working directory.
Set KA_USERS_FILE if you want it stored elsewhere.
Current Protections
/loginis rate limited by client IP.- Session cookies are HTTP-only and expire after 12 hours.
/logoutrequires POST plus a per-session CSRF token./dashboard,/users,/api/users*,/api/printers*,/account,/audit,/printers/{printer_id}/ui/*, and/p/*require a session.- printer routes also enforce per-user grants, so users only see printers they have been assigned.
/api/accountlets the signed-in user change their own password after confirming the current password./api/auditreturns recent audit events for admins.- Moonraker browser proxy traffic defaults to read-only mode. Set
KA_CONTROL_MODE=fullor-control-mode fullonly when authenticated users should be allowed to send normal Mainsail/Fluidd control commands. - The server warns when default credentials, default agent token, or insecure cookies are used.
Printer Control Mode
The server supports two control modes:
readonly
full
readonly is the default. It allows health, info, camera, UI asset, and common
Moonraker read paths, but blocks representative risky HTTP and WebSocket control
traffic such as G-code scripts, print pause/resume/cancel, emergency stop, machine
commands, and file mutation routes.
full forwards authenticated browser traffic to Moonraker without that starter
policy block. Use it only behind HTTPS with non-default credentials.
Public Exposure Notes
This is still a lightweight self-hosted auth layer. Before recommending public internet deployment, the project still needs:
- durable session storage and explicit session secret configuration
- CSRF protection for all state-changing browser requests
- rate limiting on login
- TLS deployment guide
- audit logging tied to user identity