Documentation / LemmeKnow Server

Users and authentication

If your broker is open (no sign-in), you don't need users at all: any phone that can reach the broker connects. This page is for the signed-in setup, where each phone connects with a username and an access key. See Option 2 in Setting up Mosquitto for the broker side.

How sign-in works

When a phone connects, Mosquitto's LemmeKnow auth plugin passes the phone's username and access key to a sign-in check on the same PC. LemmeKnow Server runs that check on 127.0.0.1:8765 whenever nothing else is using that port, unless AUTH_ENABLED is False in config.py. If the LemmeSee Hub is running, it already provides the check, and LemmeKnow Server leaves it to the hub.

LemmeKnow Server accepts a phone when:

  • the access key belongs to a user in the server's database,
  • that user is active, and
  • the username the phone sent matches that user's username.

Access keys are never stored as plain text. The database keeps only a fingerprint of each key, so a lost key can't be recovered, only replaced.

Managing users

LemmeKnow Server comes with user_manager.py, a command-line tool that manages users in the server's database. Run it from the server's folder.

CommandWhat it does
python user_manager.py create <username>Creates a user and prints its access key once. The username can only contain letters, numbers, underscores, and hyphens.
python user_manager.py listLists users with their username, ID and whether they're active.
python user_manager.py rotate <username>Gives the user a fresh access key and prints it once. The old key stops working.
python user_manager.py delete <username>Deletes the user permanently.
python user_manager.py create alex
Created user 'alex'
Access key (shown once): 7Hq2...

Copy the access key straight into the phone, or somewhere safe. There is no command to show it again; if it's lost, use rotate.

user_manager.py uses the database set by DB_PATH in config.py, the same one the server uses. See Configuration.

Signing in from the phone

In the app's server editor, enter:

  • Username: the username you gave to create, as shown in the Username column of python user_manager.py list.
  • Access Key: the key printed by create or rotate.

The app turns on Use TLS encryption whenever an access key is set, so the phone listener must use TLS. See Connecting phones.

What signed-in users can see

LemmeKnow Server only checks who a user is. It doesn't keep permissions, so every signed-in user gets the same access: the heartbeat, the config message, and public logs and pings. Private messages and targeted messages need the LemmeSee Hub, which adds per-user permissions, invites, and roles. See Users and Permissions.

If you run the hub on the same PC, manage users from the hub instead of user_manager.py. Both can use the same database, but the running hub doesn't pick up users that user_manager.py adds or changes until it restarts.