Skip to main content

Access and credentials — configuration

For the person deciding who can get into the system. Read admin/people.md first: it explains why a person and a login are different things, which is the assumption everything here rests on.

The first question, answered​

No screen, endpoint or export anywhere in this product reveals a password somebody chose, and none ever will. The one exception is narrow and deliberate: a temporary password an administrator set can be read back by an administrator until the person replaces it (see "Usernames and readable temporary passwords" below) — a second person already knows it by then.

Passwords are hashed with argon2 — a one-way function. The stored value cannot be turned back into the password: not by us, not by an administrator, not by somebody who steals the database.

This is asked often enough that the reason is worth giving rather than asserting:

An administrator who can read a password can act as that user. Everything they then do is recorded against the wrong person. Your audit log — the thing you hand an auditor, the thing that answers "who approved this payment" — becomes a record of what somebody appeared to do. Once that is possible it is never provable again, retroactively, for every entry already in it.

What to do instead is set a new one. See below. It is shown once, the user is made to change it, and the log records that an administrator set it — so the history stays true.

The three ways somebody gets a password​

PathWhenWho ends up knowing it
InvitationThey have a work emailOnly them
Administrator sets oneThey have no work email, or cannot waitThem and whoever set it, until their next sign-in
Reset by emailThey forgot itOnly them

Invitation — the ordinary path​

Inviting somebody creates a login with no usable password and sends a one-time link. They choose a password nobody else ever knew.

The link expires. Re-inviting somebody issues a new one and closes the old, because two live invitations for one person are two chances for the wrong one to be used.

Somebody who already has a login — because they work for another of your companies — is granted the role and not re-invited. Their password already works.

An administrator sets one — the warehouse path​

Much of a distributor's floor has no company email. A supervisor needs to fix access in the moment, in a cold room, with somebody waiting. That is a real need, and pretending otherwise is how one login ends up shared by a whole shift.

So an administrator can set a password directly. What makes it safe enough:

  • Generating one is the default. A supervisor asked to invent a password invents the same one every time. The generated one is sixteen characters and leaves out 0, O, 1, l and I, because it is read off a screen and typed into a handheld.
  • It is shown once, at the moment it is set, with a copy button. Closing the dialog is the last time anybody sees it. There is no way back to it.
  • The user must change it at their next sign-in, on by default. This is what makes the supervisor's knowledge of it expire the first time it is used.
  • Every session ends, because whoever was signed in was signed in with the password this replaced.
  • The screen afterwards shows that person as "Password handed over" rather than "Active", until they have chosen their own.
  • Until they choose their own, they can do nothing else. Every permission is refused with password_change_required, and the app shows only the change-password form. Signing out still works. A support session borrowing the seat is not held to this — it is not the one holding the handed password.
  • Only downhill. You may set the password of somebody whose permissions here are all ones you hold yourself. A custom role holding user.set_password and little else is therefore not a way to take over an administrator. Superusers and platform staff are never reachable from inside a company. The same rule applies to resetting a second factor.
  • Not on yourself. Your own password is changed in Preferences, which asks for the current one.

This needs user.set_password, which is granted to no seeded role below Administrator — deliberately. Inviting is safe; handing over a working credential for somebody else's account is a bigger capability than "administer users", and a company that wants a shift supervisor to have it grants it on purpose.

Reset by email​

The same act as re-inviting: a one-time link to somebody who has an address. There is nothing to look up and nothing to read out.

Changing the address somebody signs in with​

Change next to Signs in as on their record (user.manage). It corrects an invitation sent to the wrong inbox without closing the login and inviting again, which would lose its history:

  • Not yet accepted — a new invitation goes to the new address and every link sent before stops working.
  • Already signs in — every session ends; they sign in again with the new address and the same password. Your own address you may change too, and your sessions stay.

The same seat rule as setting a password applies: you cannot change the address of somebody who can do more here than you. The address must not be another login's, and a suspended or closed login must be reinstated first. One login serves every company of the account, so the new address is used in all of them. The change is audited as access.sign_in_email_changed with the old and new address.

Ending access​

ActWhat it doesReversible
End one sessionThat device is signed out on its next actionThe person signs in again
End all sessionsEvery deviceThe person signs in again
SuspendCannot sign in at all; every session endsYes, one click
Record a departureSuspends, ends every session, closes open invitations, marks the person as having left, and lists what they still ownedThe person and their history stay for ever

Ending a session takes effect on the holder's next action, not when their sign-in would otherwise have expired. That distinction matters when somebody has just been walked out of the building, and it is why the product records sessions rather than only tokens.

Suspension and departure end sessions as part of the act. They are not a second button somebody has to remember.

The guards you cannot switch off​

These refuse, always, and there is no setting:

  • The last administrator on a company cannot lose the role — not demoted, not removed, not suspended, not offboarded. Every product that omits this eventually locks a customer out of their own system, and the only way back is a support engineer with database access.
  • Nobody can remove their own last administrator role. Make somebody else an administrator first.
  • You cannot grant a role holding permissions you do not hold yourself. Otherwise a manager could assign the Administrator role and then hold everything.
  • You cannot act on somebody who does not have access to the company you are in. The permission is yours; the person may not be.

Roles​

The seeded roles are Administrator, Manager, Sales, Warehouse, Accounting and Read only. The roles screen shows, for each: every permission it holds with a plain-language description, and how many people hold it here — so "can we stop using this one" is answered on the screen.

The permission list is read from the product's own registry, never a written list, so a role stays correct on the day a new app ships.

Accounting reads suppliers and bills, and approves payment runs (owner decision, round 80). Since the go-live review everything about suppliers was Administrator only among the seeded roles. Accounting — the controller's and the bookkeeper's role; there is no separate seeded Controller — now holds vendor.read, vendor_bill.read, vendor_payment.read, the bill list's bill_figures.* and payment_run.approve. It still changes no supplier or bill, builds and releases no payment run, and sees no tax id or bank account in clear. Your company's own roles are not changed.

A permission split in two. When one permission becomes two, a role your company saved before the split holds the old one only. Such a role is read as holding the new one too, so nobody loses what they could do and no role is rewritten: payment_run.approve was split out of payment_run.release (round 80), so a role holding release still approves runs, and the roles screen shows it holding both. Saving the role stores both.

The roles screen (/settings/roles) lists seeded and custom roles together. The grid folds each app's permissions into areas with a level — View (*.read), Edit (*.manage), Full (Edit plus every other action in the area) — and shows special actions separately, amber where they move money, stock or access, or delete a record for good (any *.delete, item.delete first). Only enabled apps appear; a role's count is of what the screen can show.

Separation of duties is checked, not enforced: the screen lists a role's risky combinations (supplier creation with payment release, receipts with write-offs, counting with applying counts, and others in auth/separation.py) and the save review requires a reason when a change adds one or adds anything consequential. The reason is stored in the control audit log beside the change (access.role_changed) and shown in the role's history.

Choosing a seeded role for somebody on a custom role now takes them off the custom role; before, the custom role kept applying.

role.manage cannot be used from a borrowed seat ("Sign in as" or platform support).

proposal.approve_financial is flagged wherever it is granted. It is the permission that lets somebody approve drafted work that moves money — raising a purchase order, releasing a payment. It is granted to no seeded role except Administrator.

Settings, by area​

The Settings group on the roles screen has one row per area of Settings → All settings — Sales settings, Purchasing settings, Accounting settings, Document numbering settings and so on — each with an Edit level (sales_settings.manage, purchasing_settings.manage, …), plus All settings (setting.read to view, setting.manage to change every area). A setting can be changed by somebody holding its area's permission or setting.manage — except security settings, which only security_policy.manage changes. Out of the box Manager holds setting.manage and the Sales, Customers, Purchasing, Inventory, Warehouse, Approvals, Printing and Notifications areas; Accounting holds the Accounting, Tax and Document numbering areas; Sales, Warehouse and Read only change no settings. The full table, and which screens ask for which, is in All settings.

A role that holds an area's permission should also hold All settings → View (setting.read), or it cannot open the screens that show the settings.

Summary figures​

The figures across the top of a list — Open, Overdue, Disputed and Paid this month above customer invoices; Active items, Out of stock, To reorder and Stock value above items — each have their own permission, under Summary figures in Settings → Roles, one area per list. Somebody without a figure's permission does not see that figure at all: the server neither works it out nor sends it, so it is not merely hidden on their screen.

Holding a figure is not enough on its own. Each also needs the permission to read what it counts — the invoice figures need Invoices and credit memos → View, Paid this month needs Customer receipts → View as well, the stock figures need Stock on hand → View, and To reorder needs Supplier items and prices → View and Purchasing switched on. A figure never tells somebody about records their role cannot open. Figures for an app or option that is switched off (Receivables inside Sales, for example) do not appear.

FigurePermissionSeeded roles
Openinvoice_figures.openManager, Accounting
Overdueinvoice_figures.overdueManager, Accounting, Sales
Disputedinvoice_figures.disputedManager, Accounting
Paid this monthinvoice_figures.paid_monthManager, Accounting
Active itemsitem_figures.activeManager, Warehouse, Sales, Accounting, Read only
Out of stockitem_figures.out_of_stockManager, Warehouse, Sales, Accounting
To reorderitem_figures.reorderManager, Warehouse, Accounting
Stock valueitem_figures.stock_valueManager, Accounting

Administrator holds all of them. The money figures add up only documents in the company's own currency; invoices in other currencies are counted in the figure's note rather than added in.

Permissions on this screen​

PermissionWhat it allows
user.readSee who has access, and their sessions
user.manageInvite, suspend, reinstate, end sessions, change the sign-in email
role.assignChange somebody's role, remove their access
user.set_passwordSet a password for somebody else; reset a lost second factor

A support engineer working inside your company through a support session can never use user.manage, role.assign or user.set_password, whatever the account they are borrowing holds. A password or a role changed from inside a borrowed session would be indistinguishable, in your audit log, from your own staff having done it.

Multi-factor authentication​

Whether somebody has enrolled a second factor is shown on their row. An administrator can reset a lost enrolment — the broken-phone case, which happens constantly — and the person enrols again at their next sign-in. Resetting is audited, because it is a genuine reduction in that account's security until they do.

What is audited​

Every act on this screen writes an audit entry: who did it, to whom, when, and the before and after. Passwords, MFA secrets and mobile numbers are excluded from the values recorded — that they changed is in the log; what they changed to is not.

Access policies: schedules, networks, sessions and devices​

Where they are enforced, and where they are not​

Two places, both on the control plane: sign-in and token refresh. There is no third. Between refreshes nothing is re-evaluated, so a person whose hours end at six keeps working for up to the access token's lifetime — about fifteen minutes — and is then signed out with the reason.

That is a deliberate trade and the alternative was worse: evaluating a policy on every request would put a second control-plane read on the hot path of the whole product, to change an answer that changes twice a day.

A refusal at refresh ends the session rather than only declining the rotation. It has to: the client is still holding a working access token, and every request already re-reads the session, so ending it is what makes the refusal bite everywhere at once.

The timezone is stored on the policy, not looked up​

Hours are read in the timezone written on the policy, resolved when it was saved: the site's where the policy is one person's and they have a site, otherwise the company's.

The consequence, stated plainly: moving a site to a different timezone does not move the policies pinned to it. Re-save them.

The reason is that sign-in happens before any company database is opened. A company's timezone is a setting in that database and a site's is a column in it, so resolving one at sign-in would mean a second database connection on the authentication path of every sign-in, for an answer that changes about once a year.

What "lock-out protection" actually protects against​

Saving a policy that would refuse the person saving it, at that moment is refused. That catches the mistakes that happen: the wrong timezone, an allowlist typed from memory, a start date in the future.

It is not a proof that somebody can always get in. A policy permitting only Sundays, saved on a Sunday, is accepted. A role policy saved by an administrator who has a policy of their own is accepted and may still strand everybody else.

Proving "somebody can always get in" is a question about a policy set over all future time, and the honest answers to it are the two that exist: a support channel that can lift a policy directly in the control plane, and an audit trail naming who set it. Do not treat the guard as more than the cheap check in front of those.

The IP allowlist and the absent address​

A request with no client address passes the allowlist. If a proxy stops forwarding the address, an allowlist that refused would take a whole company offline — an outage caused by a security control, which is how allowlists come to be switched off permanently.

Where the address matters, the deployment is what guarantees it arrives. A policy cannot.

Device binding is not cryptographic, and does not claim to be​

It compares the session's recorded user agent and address against the ones the refresh arrived with. A user agent is self-reported, so this is not a device certificate and will not stop a determined attacker who copies both.

What it does stop is the case a distributor actually has: a refresh token lifted off a shared handheld and used from somewhere else. A session that started before the policy existed recorded neither value and is left alone — otherwise ticking the box would sign out the whole floor.

The permission is its own, and support cannot use it​

access_policy.manage is separate from user.manage, and only Admin holds it by default. The worst a mistake with user.manage does is give somebody the wrong role; the worst a mistake here does is lock everybody out at once.

Managers hold access_policy.read — they see the rules on the access screen and cannot change them.

It is also on the list of things an impersonating support session may not do. A support engineer who could widen a schedule or add an address to an allowlist could arrange their own way back in from anywhere, and the customer's audit log would show their own administrator doing it.

Every refusal is recorded​

In the control-plane audit log, as access.refused, with the reason and the person. Not the address and not the device — rule 11 — which are on the session row where the sessions screen shows them.

"Why could nobody sign in on Sunday" is a question asked on Tuesday, by which time a log line has rotated.

Roles a company defines for itself​

What changed, and what deliberately did not​

A role used to be an enum member resolved through a table written in code. It can now be a row a customer edits — which is what makes the feature useful and is also a change to what an access token means.

So it is expand-only, and the enum stays:

  • entity_roles holds a company's own roles, permission keys and all;
  • user_entity_roles.custom_role_id sits beside the existing role column, which is still NOT NULL;
  • tenant resolution prefers the row where one is set and falls back to the enum;
  • nothing already issued changes meaning, and a deployment can be rolled back with the new column simply ignored.

The enum column is not dead weight. It is the fallback role: what a holder reverts to if their custom role is retired, and what the entity switcher, the CLI and every audit row continue to read. That is why retiring a role can never strand anybody — there is always an answer to "what are they now".

Dropping the enum is the contract step and it is not scheduled. It may never be.

The guard, and why it is not optional​

_refuse_defining_what_you_lack: nobody composes — or hands out — a role holding a permission they do not hold themselves.

Without it, a Manager holding user.manage and role.assign could compose a role holding user.set_password and entity.manage, assign it to themselves, and hold everything. Through the product's supported path, leaving an audit trail that reads like ordinary administration.

It is the same rule that already applied when handing out a seeded role, moved onto a permission set. Seeded roles were safe because the sets were fixed and reviewable; a customer's are neither.

An unrestricted actor — the CLI, a migration, the seeder — passes, the way it does everywhere else in this product.

Two permissions, not one​

  • role.assign — move somebody between roles that exist. Managers hold it.
  • role.manage — create, copy, edit and retire roles. Administrators only.

Separate for the reason access_policy.manage is separate from user.manage: assigning picks from a reviewed list, composing writes the list. The guard above stops the escalation either way; what the split stops is four people each inventing a role that does nearly the same thing.

Cost on the request path​

One primary-key read per request, and only for people who are actually on a custom role. Everybody else takes the same path they always did.

That is the same shape as the session read this product already does per request, for the same reason: editing a role has to bite now rather than when a token expires.

Retiring one​

Refused while anybody holds it, with the count in the message. That is a deliberate refusal rather than a cascade: cascading would be one click that silently changed what a dozen people may do.

The database is the backstop rather than the mechanism — custom_role_id is ON DELETE SET NULL, so a role removed by some other means (a database fix) leaves its holders on their fallback rather than making the row undeletable. clear_retired_assignments() is the supported way to do that in bulk.

The permission list comes from the registry​

GET /access/roles generates it from the permission registry with each permission's own description. Never a hand-written list: a role editor built on one is wrong on the day a module ships, and it is wrong quietly.

Invitations and reset links are emailed through the email capability (the company's own account or the platform relay). With only the logging provider, nothing reaches anybody and the screens say "not emailed".

The link itself is returned (invitation_url) only to a caller who holds user.set_password and whose access here covers the person's — the same bar as setting their password, because opening the link is choosing it. Everybody else relies on the email.

POST /auth/password-reset is public, answers 202 for every address, issues at most one link per person per five minutes, sends through the first company the person can sign in to, and issues nothing when that company has no email — so it never replaces a link an administrator already handed over.

Usernames and readable temporary passwords​

users.username (lowercase, 3–64 of a-z 0-9 . _ -, unique over live rows) signs in anybody without an email; users.email is nullable, and a row must have one or the other. POST /access/usernames needs user.manage and user.set_password.

A temporary password — one set with "must change" — is sealed on the login (handed_password_sealed, envelope-encrypted under the vault's master key, bound to the user id) so POST /access/{user_id}/password/reveal can return it to a caller with user.set_password whose access covers the person's. Each read writes an access.password_revealed event to the control audit log. It is emptied when the person chooses their own password (change or invitation) or another is set, and unreadable after invitation_ttl_seconds. A password set without "must change", and every password a person chose, is only ever stored as an argon2 hash.

Sign in as (user.sign_in_as)​

Administrator only by default. POST /access/{user_id}/sign-in-as with a reason (10+ characters) returns a 30-minute, non-refreshable token for the person's seat, backed by an impersonation_grants row with kind = 'company'. The same controls as platform support apply: the credential and permission permissions (FORBIDDEN_WHILE_IMPERSONATING, now including user.sign_in_as itself) are refused inside it, it is never onto platform staff or a superuser, and only onto somebody whose permissions here are a subset of the caller's. Starting one writes access.signed_in_as (with the reason) to the control audit log; every change made inside it carries impersonation_id on its audit row in both the company's log and the platform's. DELETE /access/sign-in-as/{grant_id}, with the administrator's own token, ends it on the borrowed seat's next request.

Two-step sign-in (TOTP)​

RFC 6238 codes (SHA-1, 6 digits, 30 seconds, one step of drift), implemented with the standard library — no new dependency. The shared secret is sealed in users.mfa_secret with the vault's envelope encryption, bound to the login. POST /auth/me/mfa begins (not in force), POST /auth/me/mfa/confirm switches it on with a right code, POST /auth/me/mfa/off switches it off with one. POST /auth/login answers 401 mfa_required when the password was right and no code was sent. An administrator's DELETE /access/{user_id}/mfa clears a lost one (user.set_password, only downhill).

Known limit: a code can be used twice within its 30 seconds; there is no per-step replay record yet.