Skip to content
Free test

Users, two-step sign-in and the audit log

In development. Not available. Packages are not yet published for download.

Applies to: Reach 0.1.1, built from commit 08df4b0. There is no release.

Copied word for word from docs/admin/users-and-sign-in.md in the private Reach repository, commit 08df4b0, 21 November 2026.

The guide: Users, two-step sign-in and the audit log

Reach is in development. Its packages are not published.

For the person who runs the Reach server. Written for the build that has two-step sign-in. "From the code" means the statement comes from reading the source and its automated tests, not from a run on a Rocky machine; the install guide describes the run on Rocky Linux 9.

What a person goes through#

  1. Password. Email address and password at /signin.
  2. A code. Every user, every role. The second step is a six-digit code from an authenticator app (any app that follows the standard: time-based, SHA-1, 6 digits, 30 seconds; a password manager's built-in one works). A person who has no second step yet sets it up at their first sign-in after the upgrade, before they can see any page.
  3. Signed in. Sessions end after 60 minutes without activity and after 12 hours in any case.

Between the two steps the session reaches only the code page and the setup page, and it expires after 5 minutes. A new session ID is issued after each step. A session made before the upgrade, or before a person's second step was reset, is ended the first time it is used.

Setting up the second step#

A password alone is never enough to attach an authenticator. Whoever holds a password but no second step must show one more proof first, otherwise the first person to guess or steal a password would own the account's second step:

How the person arrivesThe proof
They open a setup link (the first owner) or an invitation linkThe link, as long as setting up the second step follows straight on in the same visit. They choose a password and go directly to the set-up page.
They open a password-reset linkNo proof: a reset link sets the password and nothing else. If they have a second step, they sign in with it afterwards. If they have none, they need an enrolment code (next row), so an administrator who issues a reset link cannot use it to attach their own authenticator to a colleague's account.
They have a password and no second step (an account from before this build, or one whose second step was reset)An enrolment code: single-use, valid 15 minutes, eight letters and digits. An owner issues one from the Users page (Enrolment code, shown once), or reach-server user reset <email> --totp prints one on the server's terminal. They sign in, type the code, and then see the set-up page. A wrong code counts like a wrong second-step code.

Without a second step, no sign-in from another machine. The moment a user is enabled and lacks one, the server refuses their password from any address that is not this machine (it says why once the password is right). They set up from the server itself or through an SSH tunnel (the tunnel arrives from 127.0.0.1), or with a setup or invitation link. Behind a reverse proxy (not supported yet) the server would see the proxy's address, not the person's.

On the set-up page the person scans a QR code (or types the setup key), then types the six digits the app shows. Reach then shows ten recovery codes, once. Each works once, in place of a code, for example when a phone is lost. They are stored only as keyed hashes (HMAC-SHA-256 under a key made from the KEK), so nobody, including you, can read them again. The person should save them in a password manager before continuing.

Things to know:

  • Upgrading from a build without two-step sign-in: every existing user has a password and no second step. Run reach-server user reset <email> --totp for each, give them the code it prints, and have them sign in from the server (or through a tunnel). Until they have, none of them can sign in from another machine.
  • The seed belongs to the session that showed it. It is stored on the half-signed-in session and goes when that session ends (5 minutes at most). A new start gives a new seed, so a seed seen once cannot be enrolled later by someone else. It is written to the user only when the person types a right code, sealed with the server's key-encryption key (KEK), AES-256-GCM, bound to that user's row. A stolen database or backup without the KEK holds no usable seeds. Someone with the whole server disk has the KEK too.
  • A code works once. The server keeps the last 30-second step it accepted for each person and refuses that step and every earlier one. One step of clock difference either way is allowed, so the server's clock should be right (use chrony).
  • A recovery code works once, and using one does not turn the second step off. Signing in with one shows how many are left.

Lockout#

WhatRule
Wrong passwords5 in 15 minutes for the same account or the same address: further attempts are refused for the rest of the 15 minutes. An attempt is counted when it starts and only one is checked at a time per account and per address, so a burst of parallel guesses is not all tried. Kept in the server's memory, so a restart clears it and two server processes each keep their own count; moving the counters into the database is a later change.
Wrong codesCounted per person across all sessions, in the database, since their last good sign-in (forgotten only after a whole day with none). 10 wrong codes pause that person's second step for an hour. Each further pause is twice as long: 1 h, 2 h, 4 h, and so on up to 7 days. A good sign-in resets the count but not the escalation; the escalation falls by one step for each quiet week. An audit row is written at the fifth wrong code (totp_failures_warning) and at every pause (totp_locked, with how many in a row), and owners see a notice on the Overview from the fifth. Slow guessing over days is therefore never quiet.
While pausedThe right code is refused too, from any session. The code page says until when. Owners see a notice on the Overview with the names, and the Users page shows "Paused until".
Lifting a pauseWait it out (the escalation stays and falls by one step for each quiet week), or run reach-server user reset <email> --unlock on the server (the escalation goes back to the start).

The pause also stops the real person. That is the price of stopping a guesser; --unlock is the way out.

Users page (owners and admins)#

Users in the navigation shows everyone in the organisation: role, status, whether the second step is on, and the last sign-in.

ActionWhoWhat happens
Invite someoneOwner or admin. Only an owner can invite an owner.Makes a link, shown once, valid 3 days, works once. The person opens it, chooses their name and password, then sets up the second step at their first sign-in.
Password reset linkOwner or admin. Only an owner can reset an owner.Makes a link, shown once, valid 1 hour, works once. It sets a new password and keeps the second step, so the person who issued it cannot sign in as them with the link alone. For someone with no second step yet, the link does not open the set-up page: they need an enrolment code from an owner as well. The person's sessions end when the link is issued, and any older link for them stops working.
Enrolment codeOwner only, for a person with no second stepShown once, valid 15 minutes, works once (see above).
Change roleOwner only, not for yourselfRoles: owner (everything, including roles), admin (policy, tokens, users), viewer (read only). The person's sessions end.
Disable or enableOwner or admin (an admin cannot touch an owner), not for yourselfA disabled person cannot sign in and their sessions end.

Invitation and reset links stop working when the person who issued them is disabled or demoted. The last active owner cannot be disabled or made an admin; the check holds the owners' rows locked, so two owners cannot remove each other at the same moment. Nobody changes their own role or status; ask another owner.

Re-authentication. Inviting, changing a role, disabling, issuing a reset link, creating a token and revoking a token, and switching AI used in the browser on or off or confirming its list (concept), each need the person to have entered their password and a fresh code within the last 10 minutes (signing in counts). If not, the page says "Confirm it is you", does nothing, and after they confirm they repeat the action. Reading pages never asks. A code used at sign-in cannot be used again for this, so wait for the app's next code if you confirm within the same 30 seconds.

Lost password or lost phone: reach-server user reset#

Run on the server, as the service user, like setup-link:

Shell
cd /
sudo -u reach-server /usr/bin/reach-server user reset ada@example.co.za --password --config /etc/reach-server/server.toml
FlagDoes
--passwordPrints a one-time password-reset link, valid 60 minutes. Keeps the second step. Ends the person's sessions.
--totpRemoves the person's authenticator and recovery codes, ends their sessions, lifts any pause, and prints an enrolment code (single-use, 15 minutes) on your terminal. Give it to them; with it and their password they set up a new authenticator, from the server or through a tunnel, and get ten new recovery codes. Use it for a lost phone with no recovery codes, for a person with no second step yet, or when someone else set the second step up.
--unlockLifts a pause and resets the escalation: the wrong-code count goes to zero and the next pause starts again at 1 hour, not at the doubled length. It also closes the owner's notice and alert about the pause. Keeps the authenticator and the recovery codes.

Give --password and --totp together for someone who has lost both. Each run writes an audit row (password_reset_issued, totp_reset, totp_unlocked) with the actor system / cli. The command never prints a hash or a seed. Resetting a second step is a command-line job on purpose: nobody inside the console, not even an owner, can switch another person's second step off.

If the only owner loses everything, this command is the way back in.

The audit log#

Every sign-in step, failure, pause, set-up, reset and user change is written to the audit log, one row each, inside the same database transaction as the change. Rows hold who (user, system or the command line), what, which user or token, the address the request came from, and short details (a role, a method). They never hold a password, a code, a recovery code, a seed, a link or a token.

ActionWritten when
signinA person finishes both steps (method: totp, recovery_code or enrolment)
signin_failed, signin_throttledA wrong password for a known account (or a password for an account with no second step from another machine); the first refusal in each 15-minute window. Attempts on unknown addresses go to the server log only, since there is no organisation to write them under.
totp_failed, totp_failures_warning, totp_lockedA wrong, replayed or unknown code; the fifth since the last good sign-in; a pause begins (with how many in a row)
signin_password_okThe password step succeeded (the person is not signed in until the code)
enrol_code_issued, enrol_code_usedAn enrolment code is issued (console or command line) and used
recovery_code_usedA recovery code is spent (codes_left)
totp_enrolled, totp_reset, totp_unlockedSet-up, command-line reset, lifted pause
reauthA person confirms with password and code
user_invited, user_created, user_role_changed, user_disabled, user_enabledUsers page and setup links
password_reset_issued, password_reset_doneA reset link is made (console or command line); it is used
token_created, token_revokedAdd machines page

The chain. Each row's hash covers the row before it, per organisation. reach-server audit verify --config <path> recomputes every organisation's chain (all of them, even after one is broken) and prints each head hash; it exits 1 and says which row is wrong if a row was edited or removed. Give it an anchor from a log line with --expect <tenant>=<head> (repeatable; the tenant is the organisation's ID on the server): the head must still be in that chain, which catches rows cut from the end and a database restored to before the anchor. The running server does the same once at start and every 24 hours and writes each head to its log as audit.anchor (or audit.chain_broken as an error), so a log collector keeps an outside copy. Ship the audit.anchor lines off this host (to your log collector or any machine the server cannot write to); an anchor kept only on the same host protects nothing against someone who controls it.

What the chain proves, honestly. It proves rows were not edited or removed one by one. Someone with write access to the database could recompute the whole chain; only a copy of a head kept somewhere the server cannot write (your log collector, a note) shows that. Keep the audit.anchor lines.

Not built yet: an Audit page in the console and export of the log. Read it with reach-server audit verify (heads only) or the database today.

Listening beyond this machine#

By default the server listens on 127.0.0.1:8443, reachable only from the machine itself. To let other machines (Reach agents, the read-only programs on staff machines, and administrators' browsers) reach it, set the listen address in server.toml:

toml
[server]
public_url   = "https://reach.example.co.za:8443"
listen       = "0.0.0.0:8443"

The server starts on such an address whoever has not set up the second step yet, so an invitation that someone opened and left unfinished never stops the server, or its agents, at the next restart. A password alone is still not enough on the network: each person without a second step is refused from any other machine at sign-in (above), and a password-reset link never lets anyone set one up. At start-up the server writes one warning to its log naming them, for example:

{"level":"WARN","msg":"server.users_without_second_step","listen":"0.0.0.0:8443","count":1,"users":"ada@example.co.za","hint":"these people cannot sign in from another machine until they set up two-step sign-in: ..."}

Each of them signs in on the server itself, or through an SSH tunnel to it, with an enrolment code from an owner (Users page) or from reach-server user reset <email> --totp, and sets up their authenticator. Someone invited later uses their invitation link from anywhere and sets up the second step before any page opens. Easiest order on an upgrade: have everyone set up their second step first, then change the address.

If you changed public_url first, the tunnel stops working. The console accepts a sign-in or any other form post only when it comes from its own address (console_url if set, otherwise public_url). Once public_url is the network address, a sign-in through the tunnel at https://localhost:8443 is refused with "Forbidden: the request did not come from this site" when the client is not a browser. A current browser at the tunnel address is accepted whatever public_url says, because it states that the request comes from the same site; the refusal is what a script, curl or any other client gets when it sends no such statement and its Origin is not public_url's (a proxy or browser extension that strips the header does the same). The refusal says how to recover. To recover: set public_url back to https://localhost:8443 and listen back to 127.0.0.1:8443, restart the server, have every person finish their second step through the tunnel, then change both again and restart. (Better: finish everyone's second step before you change either.)

A separate address for agents. To keep the console on this machine and still let agents on other machines reach the server:

toml
[server]
listen       = "127.0.0.1:8443"        # the console, this machine only
agent_listen = "0.0.0.0:8444"          # agents only
public_url   = "https://reach.example.co.za:8444"   # what goes into enrolment tokens: the agents' address

Each listener answers 404 to the other's routes: the agent address serves /api/agent/v1/ and the health checks and nothing else (no sign-in page, no console); the console address serves no agent routes. The check above applies to the console listener only. If the console has its own name, set console_url (https://...); the same-origin rule and the links the Users page makes use it instead of public_url.

Both listeners use the same certificate, so it must be valid for the names people and agents use. Firewall: open only the listener's TCP port, from the networks that need it. See firewall and ports.

Sign-in with an organisation's own identity (not in this build)#

Each user records how they sign in (identity_source, today always local: a password held here), and sessions and roles do not depend on it, so OpenID Connect (Entra ID, Google) can be added without changing them. The configuration has a place for providers, [[identity.oidc]]. This build refuses to start if one is set, with "not available in this build", rather than ignore it and leave people thinking it works.