Managing Users (Keycloak)

What is Keycloak?

Keycloak is the “login system” that sits in front of TracePcap. Instead of TracePcap keeping its own list of usernames and passwords, it hands that job to Keycloak — a separate, well-established tool that owns the login page, stores accounts securely, and checks passwords. When someone opens TracePcap, Keycloak asks them to sign in and only then lets them through.

The practical upshot: to give someone access, you create an account for them in Keycloak (using its admin console, below). You don’t add users inside TracePcap itself — there is no user list there. Think of Keycloak as the reception desk that issues the passes; TracePcap just checks the pass.

Application logins are managed in the bundled Keycloak identity provider, not in TracePcap itself. This page covers creating and managing users in the tracepcap realm. It assumes authentication is already enabled — see Authentication (OIDC / Keycloak) for how to turn it on.

Note

Users only exist when authentication is enabled (the docker-compose.prod.yml overlay). The base stack runs with no login, so there are no users to manage.

Prerequisites

The stack must be running with the production overlay:

PUBLIC_URL=http://localhost:8888 \
  docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build

You also need the Keycloak admin credentials. These have no default — set KEYCLOAK_ADMIN and KEYCLOAK_ADMIN_PASSWORD in .env or the production overlay aborts before starting anything.

Create a user via the admin console

This is the normal way to add a user after deployment. Changes take effect immediately — no rebuild or restart.

  1. Open the Keycloak admin console at <PUBLIC_URL>/admin (e.g. http://localhost:8888/admin) and sign in with the Keycloak admin credentials.

  2. In the top-left realm selector, switch from master to tracepcap.

    Warning

    Always create app users in the tracepcap realm. Users created in the master realm are Keycloak administrators and cannot log in to TracePcap.

  3. Go to Users → Add user.

  4. Fill in Username (required). Optionally set Email, First name, and Last name. Leave Email verified on if you don’t run email flows.

  5. Click Create.

  6. Open the new user’s Credentials tab → Set password.

  7. Enter and confirm a password. Turn Temporary off unless you want to force a password change at first login (email-based reset flows are not configured offline, so a temporary password must be changed by the user at the login screen).

  8. Click Save, then confirm in the Set password? popup that appears.

The user can now log in at <PUBLIC_URL> with that username and password.

Reset a password

Users → select the user → Credentials → Reset password. Set a new password (again, leave Temporary off), click Save, and confirm in the Reset password? popup that appears.

Disable or delete a user

  • Disable (revoke access, keep the account): Users → select the user → Details → toggle Enabled off → Save.

  • Delete (remove entirely): Users → select the user → Action menu (top right) → Delete.

Seeding users in the realm export (optional)

To ship a deployment with users pre-created on first boot, add them to keycloak/realm-export.json. The realm is imported automatically on startup (start --import-realm). This is how the default analyst demo user is provided.

Add an entry to the users array of that file:

{
  "username": "analyst2",
  "enabled": true,
  "emailVerified": true,
  "firstName": "Second",
  "lastName": "Analyst",
  "email": "analyst2@example.com",
  "credentials": [
    {
      "type": "password",
      "value": "change-me",
      "temporary": false
    }
  ]
}

Warning

The realm export stores the password in plaintext and is committed to the repo. Use it only for demo/default accounts and always change these credentials for any real deployment. Prefer the admin console for real users.

Import only runs against a fresh realm. Keycloak’s data lives in its container, so re-import requires recreating it:

docker compose -f docker-compose.yml -f docker-compose.prod.yml \
  up -d --build --force-recreate keycloak

Note

--force-recreate on the bundled Keycloak resets its in-container state, so any users you created through the admin console will be lost and the realm re-seeded from the export. Back up first if needed — see Backup & Restore.

Giving someone a role

TracePcap’s four roles, viewer, analyst, lead and admin, are client roles on the tracepcap client. What each may do is set in TracePcap (see Roles and Permissions); who has which is set here.

The usual way is to give the role to a group, so everyone in it has it:

  1. In the admin console, open Groups and select the group (or create one).

  2. Open Role mapping → Assign role.

  3. Change the filter to Filter by clients, select tracepcap and the role (for example analyst), and click Assign.

To give one person a role directly, do the same from Users → the user → Role mapping. Groups that come from AD/LDAP work the same way: Keycloak assigns their roles.

The change takes effect at the user’s next sign-in (or token refresh, within minutes). Someone with none of the four roles gets the default role set in TracePcap (Analyst unless an admin changes it).

Upgrading an existing install: the realm import only runs when Keycloak first starts, so an existing realm has only admin, on a client still called tracepcap-frontend. First rename the client (see Upgrading from v0.4: the client was renamed), then create viewer, analyst and lead yourself: Clients → tracepcap → Roles → Create role, one for each name.

With login off there are no accounts and no roles. Whether admin-only settings can be changed is then set for everyone by SYSTEM_SETTINGS_EDITABLE (see Environment Variables).

Notes

  • The realm defines four client roles on the tracepcap client: viewer, analyst, lead and admin. A signed-in user with none of them gets TracePcap’s default role (see Roles and Permissions).

  • Self-service registration and email-based password recovery are off by design for offline/air-gapped use. User creation and password resets go through the admin console.