JovAI Server — Multi-User Mode#
Upgrade a working single-user JovAI Server install to secure multi-user mode. Users sign in through Keycloak (open-source identity management), and each person's agents, sessions, and files are isolated under their own operating-system account.
This is a system-administrator task. It assumes comfort with Linux, Docker, and nginx.
What changes from single-user
The single-user install runs everything as you, no login required. Multi-user mode adds a login screen (Keycloak) and runs each user's work under their own Linux account. Nothing about the single-user install has to be undone — you're adding an identity layer and switching on two environment variables.
How it fits together#
Browser ──HTTPS──▶ nginx (TLS termination)
├── /auth/* ──▶ Keycloak (Docker, port 8081)
└── /* ──▶ JovAI Server (port 8080: web app + API)
JovAI Server ──validates login token──▶ issued by your Keycloak realm
JovAI Server ──runs work as the user──▶ per-user Linux accounts (isolation)
- Keycloak issues signed login tokens. The web app sends users there to sign in, then attaches the token to every request.
- JovAI Server cryptographically verifies each token (signature, expiry, issuer, audience) and maps the Keycloak username to a Linux account.
- Per-user isolation — the server performs each user's work as that user over SSH, so ordinary OS permissions are the security boundary. Every Keycloak username must match a Linux username on the server.
Requirements#
- A completed, working single-user install (
jov serveruns). - A Linux host. Multi-user mode depends on per-user execution and is not supported on Windows.
- A DNS name for the app (e.g.
jovai.yourcompany.com) with a TLS certificate — Let's Encrypt is fine. - Docker with the Compose plugin.
- nginx (or an equivalent reverse proxy).
1. Install Keycloak#
Create /opt/keycloak/docker-compose.yml:
services:
postgres:
image: postgres:14
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "CHOOSE-A-DB-PASSWORD"
volumes:
- ./postgres-data:/var/lib/postgresql/data
restart: unless-stopped
keycloak:
image: quay.io/keycloak/keycloak:24.0.1
command: start
depends_on: [postgres]
environment:
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
KC_DB_USERNAME: postgres
KC_DB_PASSWORD: "CHOOSE-A-DB-PASSWORD"
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: "CHOOSE-AN-ADMIN-PASSWORD"
# The public URL users reach Keycloak at (through nginx):
KC_HOSTNAME_URL: https://jovai.yourcompany.com/auth
KC_HOSTNAME_ADMIN_URL: https://jovai.yourcompany.com/auth
KC_HOSTNAME_STRICT: "false"
KC_HTTP_ENABLED: "true" # TLS terminates at nginx
KC_PROXY_HEADERS: xforwarded # trust nginx's X-Forwarded-* headers
KC_HEALTH_ENABLED: "true"
ports:
- "8081:8080"
restart: unless-stopped
Start it:
Keycloak now listens on localhost:8081 over plain HTTP — nginx provides the
TLS in front of it.
Prefer a dedicated subdomain?
To serve Keycloak at auth.yourcompany.com instead of the /auth path,
set KC_HOSTNAME_URL to that subdomain and give it its own nginx server
block. Everything below works the same with the URLs swapped.
2. Configure nginx#
In the server block for jovai.yourcompany.com (alongside your TLS config):
# Keycloak, proxied under /auth/
location /auth/ {
proxy_pass http://localhost:8081/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
# JovAI Server (web app + API), including WebSockets
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 300s;
}
Reload nginx, then confirm https://jovai.yourcompany.com/auth/ shows the
Keycloak page.
3. Configure the realm#
Sign in to the Keycloak admin console (/auth/ → Administration Console,
user admin).
- Create a realm — realm dropdown (top-left) → Create realm.
Give it a name (e.g.
JOVAI); it must matchKEYCLOAK_REALMlater. - Create the web-app client — Clients → Create client:
- Client ID:
jov-ui - Type: OpenID Connect, public ("Client authentication" off)
- Standard flow: on; Direct access grants: off
- Valid redirect URIs:
https://jovai.yourcompany.com/* - Valid post-logout redirect URIs:
https://jovai.yourcompany.com/* - Web origins:
https://jovai.yourcompany.com
- Client ID:
- Create team roles — Realm roles → Create role. A team is a realm
role prefixed
ns-. For a team calledacme, create rolens-acme. - Create users — Users → Add user, once per person:
- Username must exactly match their Linux username (next step).
- Under Credentials, set an initial password (mark it temporary so they choose their own at first login).
- Under Role mapping, assign their team role (e.g.
ns-acme).
4. Create matching Linux accounts#
For every Keycloak user, create a Linux account with the same username:
Each user's JovAI data will live in their own ~/.config/lit/.
5. Turn on multi-user mode#
Run JovAI Server as a systemd service (replacing the single-user autostart).
Create /etc/systemd/system/jovai-api.service:
[Unit]
Description=JovAI Server (multi-user)
After=network.target docker.service
[Service]
Type=simple
User=jovai
Environment=LIT_LOCAL_MODE=false
Environment=LIT_MULTI_USER=true
Environment=KEYCLOAK_AUTH_SERVER=https://jovai.yourcompany.com/auth
Environment=KEYCLOAK_REALM=JOVAI
Environment=KEYCLOAK_SSL_REQUIRED=external
Environment=LIT_CONFIG_DIR=/etc/jovai
ExecStart=/path/to/venv/bin/jov serve --host 127.0.0.1 --port 8080
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
The issuer must match exactly
KEYCLOAK_AUTH_SERVER + KEYCLOAK_REALM combine into the token issuer
the server expects: <KEYCLOAK_AUTH_SERVER>/realms/<KEYCLOAK_REALM>.
With the layout above that is
https://jovai.yourcompany.com/auth/realms/JOVAI. If these don't match
the tokens Keycloak issues, every login is rejected.
A few supporting steps:
# Dedicated service account (not root):
sudo adduser --system --group --shell /usr/sbin/nologin jovai
# Global config dir (holds SSH trust keys under keys/):
sudo mkdir -p /etc/jovai && sudo chown jovai: /etc/jovai
sudo systemctl daemon-reload
sudo systemctl enable --now jovai-api
6. Point the web app at Keycloak#
The web app reads its runtime settings from assets/env.js inside the
installed package. Find and edit it:
Set these three values:
window['env']['keycloakUrl'] = '/auth';
window['env']['keycloakRealm'] = 'JOVAI';
window['env']['keycloakClientId'] = 'jov-ui';
Re-apply after upgrades
A pip install --upgrade overwrites env.js. Keep a copy of your edited
version and re-apply these lines after each upgrade.
7. First login and per-user trust#
- Visit
https://jovai.yourcompany.com. You should be redirected to the Keycloak sign-in page. Sign in as one of your users. - Establish trust for that account. The platform asks for the user's
Linux password once; it uses this to generate a dedicated SSH key
(stored under
/etc/jovai/keys/) and authorize it for the account. From then on the server acts as that user without any password. - Repeat for each user.
8. Verify#
- Open
https://jovai.yourcompany.com/auth/realms/JOVAI/.well-known/openid-configuration— it returns JSON, andissuermatches the value from Step 5. - Signing in redirects to Keycloak and back to the app.
- Two different users each see only their own agents and sessions.
journalctl -u jovai-api -fduring a sign-in showsToken validation passed for user: <username>.
Troubleshooting#
| Symptom | Likely cause |
|---|---|
| "Invalid redirect URI" at login | The client's Valid redirect URIs don't cover your app URL |
Login page loads over http:// or the wrong host |
KC_HOSTNAME_URL / KC_PROXY_HEADERS wrong — Keycloak isn't seeing nginx's forwarded headers |
Log: Invalid issuer: … expected: … |
KEYCLOAK_AUTH_SERVER / KEYCLOAK_REALM don't match the token issuer — compare with the .well-known URL above |
Log: Token validation failed |
The token isn't signed by the realm's current keys (wrong realm, or Keycloak was rebuilt) |
Log: Invalid audience |
Realm/client changes removed the default account audience — restore the defaults |
| "Trust not established" for a user | Step 7 not done for that account, or the Linux username ≠ the Keycloak username |
| CORS errors in the browser console | The client's Web origins is missing your app origin |
Need a hand? Send your journalctl -u jovai-api output and a description of
what you saw to your JovAI contact.