Running the service
Accounts and roles
The ways somebody signs in to the dashboard, what each role may do, and how accounts are created and reset.
Who may open the dashboard is a deployment decision, made once in the environment. Who may do what, once they are in, is a role on their account — and every role is enforced on the server by route, not only by what the interface offers.
The two ways in
Section titled “The two ways in”Authentication__Mode decides, read at startup. In the shipped Compose file it comes from
CONTACTMESH_AUTH_MODE in .env, which has no default: forgetting it is a refusal to start rather than
a deployment quietly serving every contact to anything that can reach the port.
| Mode | How somebody signs in | What it needs |
|---|---|---|
Password | A local account’s password, or a sign-in provider, and a session cookie | A seeded first administrator. Nothing from Microsoft |
EntraId | Microsoft Entra ID through the server and a session cookie; for this release also a Microsoft sign-in in the browser and a bearer token | The dashboard app registration: directory ID, audience, client ID and scope; for the sign-in through the server, its redirect URI and client secret |
None | No sign-in at all | An isolated demo that says so: Authentication__IsolatedDemo=true, the in-memory Graph fixture, and no file or database source or stored credential |
None is for a demo that holds nothing real, and only one that says so. The API refuses to start in
None against a real Microsoft 365 tenant, without Authentication__IsolatedDemo=true, and over a
database that holds a file or database source or a stored credential: a file or database source reads
real data whichever Graph the stack talks to, and with no sign-in the dashboard and every /api/v1
route serve it to anything on the port. A running demo refuses the same at the door: creating or
changing a file or database source, reading a file’s sheets or columns for one, and storing a
tenant’s credential or a database password, are refused with a sentence saying sign-in has to be on. The image is real Graph unless told otherwise, so a
demo names the fixture too, with Microsoft365__UseFakeGraph=true. Password needs no Entra registration, so these
refusals always have a way out that does not involve Microsoft. Anonymous access behind a trusted proxy
is not supported; put the proxy in front of a Password deployment instead.
In EntraId mode all four values are required and an empty one is refused at startup. An empty string
is not an absent key: Compose substitutes unset variables as empty, and the API used to start cleanly
with an authority of https://login.microsoftonline.com//v2.0, report itself healthy, and answer 401
to everybody.
The app registration must issue version 2.0 access tokens: requestedAccessTokenVersion set to 2 in
its manifest. Entra issues version 1.0 unless the manifest says so, and ContactMesh refuses every one of
them; the log says so once, and each refused request’s audit row reads Version 1.0 token. The
audience may be given as the registration’s client ID or as api:// with it — both are accepted.
Changing the mode is a restart. There is no switch in the app.
What differs after that
Section titled “What differs after that”In Password mode a sign-in is a session kept on the server, and the cookie — HttpOnly,
SameSite=Strict — carries nothing but its key. A session lasts SessionHours from sign-in — eight by
default, at most 24 — however busy it is, and ends sooner once its person has done nothing for the
sign-in policy’s Idle limit: eight hours by default, between five minutes and a day, set on Settings ›
Security › Sign-in policy and no longer than Authentication__IdleMinutes where the host sets it. At the defaults a
session therefore ends at its hours, not for idleness. The dashboard asks the server every few
seconds while a tab is open, and that does not count; what its person presses, types, scrolls or moves
the pointer over does, and so does any change. The cookie goes when the browser closes. Every request
reads the session and its account again, so a session may do what its account may do now, not what it
could when it began, and signing out ends the session on the server: a copy of the cookie opens
nothing. Sessions began to be kept on the server with an upgrade, and everybody signed in once more
after it.
Over HTTPS the cookie is __Host-contactmesh.session, which a browser keeps for the dashboard’s host
alone. A change made with the cookie is accepted only from the dashboard’s own page, which adds a header
no page elsewhere can.
Sign-in providers — Microsoft Entra ID, or another OpenID Connect provider — are added on Access ›
Sign-in in either mode, and a sign-in through one ends in a session like a password’s;
Sign-in providers has the rest. In EntraId mode the dashboard
signs its people in through the server once Microsoft Entra ID is added there, and everything below about
sessions applies to them.
Until then, and for this release beside it, an EntraId deployment also takes the dashboard’s bearer
token, as it did before. That path is deprecated: every answer to a token carries a Deprecation header,
and it goes in the next release. Its role comes from the token’s roles claim — ContactMesh.Viewer,
ContactMesh.Operator, ContactMesh.Admin — assigned to people in Entra. The token must also carry the
dashboard’s delegated scope, ContactMesh.Access; a token a service obtained for itself carries none
and is refused, whatever role it holds, and so is an ID token, which names the roles but grants nothing.
A token keeps no session of its own — no list, no idle limit, no session limit — and is honoured until it
expires, about an hour after Entra issued it, whatever happens in Entra in between. An Admin who signed in
with one reaches Access to add the provider. Passwords sign in on an EntraId deployment once an
administrator has made a local account there.
Signing in, and what a refusal says
Section titled “Signing in, and what a refusal says”Five failed attempts lock an account for fifteen minutes; both numbers are configurable. Attempts that arrive together are each counted, so a burst gets no more guesses than the limit allows.
The lock holds back browsers that have never signed in to the account, and not the one its owner uses. A successful sign-in leaves a cookie of its own in that browser for ninety days, and a sign-in that brings it is let through a lock, so somebody guessing at a known username cannot keep its owner out. That browser’s own wrong passwords count against it in the same way, so a copied cookie buys no extra guesses. Every lock is a warning in the log, with the account’s ID, and so among the recent problems on Help & support: somebody may be guessing.
A refused sign-in says the same whatever the reason. An unknown username, a wrong password, a locked account, a disabled one and an expired temporary password give one message, in the same time, so the form cannot be used to find out who has an account or whose is locked. The message names the lockout rule instead — how many failed tries lock an account, and for how long — which is the same for everybody. Somebody it does not help asks an administrator: Access shows whether an account is locked, and until when, disabled, or on a temporary password that has expired.
The form is throttled as well: ten attempts a minute for one username, counted whether or not an
account has it, and thirty a minute from one address. Past either, the form asks for a minute’s wait.
Both numbers are configurable, as SignInAttemptsPerAccount and SignInAttemptsPerAddress. Behind a
reverse proxy the address is the one the proxy reports, believed only when the proxy connects from a
network the API trusts: loopback, the container’s own networks, which a proxy on the host comes
through, and any named in TRUSTED_PROXY_NETWORKS. Behind any other, every client shares the
proxy’s address, and the thirty with it.
The roles and what they hold
Section titled “The roles and what they hold”Every route requires one permission, named feature.verb, and a role is the set of permissions it holds.
There are three built-in roles, and they separate reading from operating from administering: Viewer holds
what reads, Operator adds what runs the work, and Admin holds every permission. Custom roles, a role given in
one tenant, the list editor of one source list, and local groups are on Roles and access.
| Area | Viewer | Operator adds | Admin adds |
|---|---|---|---|
| Overview | overview.read: the Overview, the bell, statistics and search | ||
| Source lists | sources.read: the lists, their rules and the findings the rules make, checks for changes and pictures | sources.run: check for changes, full re-read and sync, pause and resume, the access probe, refetch pictures | sources.edit: create, change and delete a list, its rules and its column map; sources.inspect: what the source system holds — a database’s profile and columns, a workbook’s sheets, a directory preview, a contact’s picture |
| Contacts | contacts.read: the contacts and their pictures, where each was delivered, and its history | contacts.erase: find a person in everything ContactMesh holds, erase them, and lift their suppression | |
| Publications | publications.read: publications, their audiences, rollouts and rule sets | rule-sets.edit: rule sets | publications.edit: create, change, dry-run, archive and delete; audiences.edit: groups and individual recipients; publications.deliver: start, pause, resume, reconcile everybody, move a rollout on; publications.sign-off: sign off a preview |
| Calendars | calendars.read: calendar sources and their events, calendar publications, their dry runs and where each was delivered | calendars.run: read a source now, send one mailbox’s calendar again | calendars.edit: create, change and delete sources and publications, dry-run, pause, resume, archive and restore; calendars.sign-off: sign a publication off for delivery |
| Field sets | field-sets.read | field-sets.edit | |
| Recipients | recipients.read: recipients, folders, plans and what is held | recipients.run: the verbs on folders, one or many | recipients.remove: remove a recipient’s record; adoption.resolve: read and answer adoption questions |
| Held deletions | deletions.approve | ||
| Lost and found | lost-and-found.read, lost-and-found.export, lost-and-found.restore, lost-and-found.erase | ||
| Contact exports | exports.read, exports.manage | ||
| Directory | directory.read | directory.refresh: the directory and the audiences’ membership | |
| Phones | devices.read: device groups, their enrolment codes (never a code itself) and the phones | devices.manage: create, change and delete a device group, and a phone’s label and notes; enrolment-codes.issue: issue and withdraw a code; devices.approve: approve, reject, revoke and move a phone; reports.review: read and answer the reports phones send about contacts | |
| Tenants | tenants.read | tenants.manage; credentials.manage: a tenant’s credential, a database source’s login, a push source’s key, a phonebook’s token and a notification channel’s secret | |
| Running the service | operations.read: the queue, the worker, schedules, capacity, settings and alerts | worker.control; schedules.run: pause, resume and run now; capacity.edit; settings.edit: the queue’s settings; alerts.acknowledge | schedules.edit: when a schedule runs; retention.edit: how long records are kept; support.diagnostics: the diagnostics bundle and recent problems; licence.manage: install a licence; notifications.manage: notification channels, outgoing mail and the delivery log |
| Audit | audit.read: the audit trail; audit.export | ||
| Access | accounts.read: the accounts, their roles and groups, with how many sessions each has running; accounts.manage: create, change, reset, list and end an account’s sessions, and delete; roles.manage: define, change and delete a custom role; access.grant: give a role and take it away; sign-in.manage: the sign-in policy — who must use a second factor, and which kinds | ||
| The demo scenario | demo.run, with the in-memory Graph only |
The health summary, the runtime and the support contact need only a session with a role. Your own
password, your own sessions and your own second factors are yours, whatever your role. Some of an Admin’s
changes also ask for a recent proof of who is asking; Second factors and
security lists them. In EntraId
mode the app roles ContactMesh.Viewer, ContactMesh.Operator and ContactMesh.Admin are these three
roles. A refusal names the permission that was missing and the role that holds it, and a control the
signed-in role may not use stays on the screen, disabled, saying which role it needs.
Assigning an individual and assigning a group are one permission, because they are the same decision
about who receives somebody’s contacts. Pausing, resuming and running a schedule are an Operator’s
(schedules.run): they are reversible and say so on the row, where changing when it runs
(schedules.edit) outlives the request. Shortening a retention window erases what it no longer keeps,
the audit log and the lost and found among them, so it is an Admin’s apart from the queue’s settings.
Some reads need Admin, which is unusual enough to be worth saying. Adoption questions are the one place the product lists the cards already sitting in a recipient’s own folder, by name and address. The lost and found holds contacts ContactMesh has destroyed, lifted out of the mailbox they belonged to. Contact exports name the directory a full dump of the address book is written to. A source’s profile names the customer’s own systems and the login this deployment signs in with. The diagnostics bundle describes every tenant in the installation and is made to be sent away. Hiding a navigation item is not a gate; these are.
Reading the account list is an Admin’s too. It names every account’s role, whether it is locked and on a temporary password — which accounts are worth guessing at, and which are being guessed at now — so Access appears in the navigation only for whoever reads the accounts across the deployment: an Admin. So does the audit trail, which records every account’s sign-ins, lockouts and refusals as well as who changed what: the Audit page, a source list’s own audit on its page, and a folder’s Pause history are an Admin’s.
Creating an account
Section titled “Creating an account”A username, an optional display name and, if it should have one, a built-in role across the deployment;
any other role is given in its pane. Usernames are compared case-insensitively, so Anna
and anna are the same account, and have at most 256 characters, as many as a sign-in reads.
ContactMesh generates the initial password and shows it once, to be handed over; nothing keeps it but the account’s hash. It is a one-use key, not a password the account keeps running on: it opens the account for 72 hours, and the first sign-in with it asks for a new password before anything else. One not used in time opens nothing, and Access says temporary password expired until a reset gives another.
Passwords
Section titled “Passwords”A password somebody chooses has at least MinimumPasswordLength characters — fifteen, and never fewer
whatever the configuration says, while a password is the only thing a sign-in asks for — and at most
1,024, as many as a sign-in reads. A script that
sends a temporary password through the API instead of having one generated is held to the same rules,
and its password expires alike.
Every new password is also refused when an attacker would try it early: one of the 100,000 passwords
seen most often in breaches, as the UK’s National Cyber Security Centre lists them, or another
well-known one; a sequence or keyboard walk such as 1qaz2wsx3edc4rfv; a repetition; or common words
and the account’s own names with little else, such as Summer2026! or anna.meier-2026. The lists it
is checked against ship with ContactMesh, so no password leaves the server. There are no rules
about digits or capitals, and passwords never expire; several unrelated words make a good one.
Passwords are stored as salted PBKDF2 hashes of 220,000 rounds; one stored before that keeps working and
is rehashed at its next sign-in.
Resetting a password, and the forced change
Section titled “Resetting a password, and the forced change”An administrator cannot read a password. The way back in for somebody locked out of their own account is Reset password, behind the … of the account’s row or its pane, which generates a temporary one and shows it once, marks the account must change password, clears the lockout and the failed-attempt count, and bumps the account’s security stamp — which ends every session that account already holds, everywhere, at once. Like an initial password, it opens the account for 72 hours.
Your own password is changed, not reset: Change password, on Your account › Profile in the menu under your name, asks for the current one and a new one. A reset asks for nothing, so the server refuses one on the account you are signed in with; a session left open at somebody’s desk could otherwise set a password of its choosing and keep the account.
At the next sign-in the dashboard shows nothing but the change-password form, and the server holds the session to it as well: until the password is changed, the session can read who it is, change the password and sign out, and every other request is refused. A temporary password opens nothing else, whatever it is typed into. The form asks for the current password again, so a stolen session cannot silently take the account over, and the new one has to meet the minimum. Changing it ends the account’s other sessions and goes on as a new session with a new key: the cookie it had opens nothing after it.
Disabling an account and changing its role move the same stamp, so the account’s sessions end on their next request and whoever holds them signs in again to what the account may now do. A session reads its account’s role on every request in any case, so a demoted administrator loses Admin at once. A role given or taken away in the pane ends no session: the next request has what the account holds now.
A password reset leaves the account’s second factors in place: the next sign-in asks for one after the temporary password, before the new password is chosen. For somebody who lost theirs, Reset second factor beside it removes them; Second factors and security says what it does and what to check first.
Sessions
Section titled “Sessions”Your account › Sessions, in the menu under your name, lists every browser signed in to your account: the browser and system it says it is, the address it signed in from, when it signed in, when it was last used and when it ends, with the one you are using first. Every row has its verb, Sign out, which asks first: on yours it signs this browser out, as the menu does, and on another it ends that session. Sign out others ends all of them but yours, and says why it is shut while no other browser is signed in. A browser signed out this way is refused at its next request.
An account has at most SessionsPerAccount sessions running at once: five by default, between one and
fifty. Signing in once more ends the session its person used least recently, which then says so.
On Access › Accounts, the Sessions column counts each account’s running sessions. The row opens the
account in a pane beside the table, its roles and every browser signed in to it, as its person sees them:
End session ends one, and End sessions — there and in the row’s menu — ends them all, without
changing anything else about the account. Beside it, Forget browsers forgets every browser that skips the account’s second step
(Remember this browser), so each asks for it again; it is
shut, saying why, where none does. Listing, ending and forgetting are accounts.manage’s, and ask for a
recent proof of who is asking. Your own are on Your account › Sessions and Second factor.
Every session of an account also ends when the account is disabled, deleted, given another role, has its password reset or changed — the change carries on as a new session — or its second factors reset, and when the host resets its access. A sign-in still at its second step, or setting a factor up, is not listed and counts towards no limit until it is complete. The audit log records who ended which sessions and why. The live status in the status bar ends with the session it was opened on.
A browser whose session has ended shows the sign-in form, and says why: idle too long, signed out from another session or by an administrator, past its hours, the session limit, or a change to the account.
What the screen refuses
Section titled “What the screen refuses”Six guards, all on the server:
- You cannot remove your own administrator access — neither by disabling yourself nor by changing your own role away from Admin.
- You cannot reset your own password; you change it, with the current one.
- You cannot reset your own second factor; you change it on Your account › Second factor.
- You cannot delete the account you are signed in with.
- At least one enabled administrator must remain: an account holding Admin across the deployment by its own assignment, since a group can lose its members by a change nobody meant as taking access away. The last one cannot be disabled, demoted, lose its Admin or be deleted — not even by two administrators removing each other at the same moment, because account changes are made one at a time.
- An account’s own role on Edit is Viewer, Operator, Admin or none; any other is refused.
Disabling is reversible and keeps the row, its history and its password. Deleting removes the account entirely.
The seeded administrator
Section titled “The seeded administrator”On first start in Password mode, and only while the accounts table is completely empty, ContactMesh
creates one administrator from configuration: CONTACTMESH_ADMIN_USERNAME with
CONTACTMESH_ADMIN_PASSWORD.
There is no default for either. The API refuses to start without them, refuses a password the policy
refuses, and refuses the names anybody would try first — admin, administrator, root and the like —
because a self-hosted tool with a guessable first account is worse than one that will not start, and
the lock can be aimed at a name somebody knows.
The seeded account is created with must change password, so the value in .env gets somebody through
the door once and then stops being the password — and only within 72 hours of the first start, like
any temporary password; past them, the host gives the account a new one (below). It is an ordinary
administrator afterwards: it can be demoted or deleted like any other, once a second enabled
administrator exists.
It is seeded once and never again. The check is “are there any accounts at all”, not “does this
username exist” — so changing CONTACTMESH_ADMIN_USERNAME later does nothing, and a forgotten sole
administrator is not recovered by restarting the container. Every account is in the database, and the
database is what has to be restorable.
When nobody can sign in
Section titled “When nobody can sign in”A forgotten password, a lock, or an account switched off by mistake is fixed by another administrator with Reset password or Edit. When there is none — a sole administrator — the host can do it:
docker compose run --rm api reset-access <username>It prints a temporary password once, good for 72 hours, switches the account on, lifts any lock,
removes the account’s second factors and ends every session the account held; the next sign-in asks for
a new password at once, and then for a second factor to be set up where the sign-in policy requires
one. The audit log records it under host.
Whoever can run it already holds the database and its keys, so it asks for nothing more. It changes
nothing for a name nobody has, and lists the administrator accounts instead.