Create the administration accounts
You give each administrator a named account, protected by a password and a second factor (a code received by e-mail, or an authenticator app chosen by the account), and you keep an emergency door. Local accounts work with or without an identity provider (sign-in through a provider); the reasoning is in ADR 0094 (external site).
Add an account
- Open Settings › Accounts and add the account, leaving the invitation ticked.
- The person receives a single-use link, valid 72 hours, to choose their password (twelve characters at least, hashed with bcrypt).
The application must therefore be able to send mail (MAIL_*, and PUBLIC_URL to write the link: outside development, with no reachable PUBLIC_URL the link points to localhost, with a warning at startup). See Get your e-mails delivered. “Reset password” (same tab) and “Forgot password” (sign-in page) send a link valid one hour. The administrator never sees the link or the password.
The second sign-in step
A six-digit code received by mail follows the password (ten minutes, five tries), on by default. AUTH_LOCAL_SECONDE_ETAPE=false switches it off: keep it for an instance with no mail, or behind an access proxy that imposes its own second factor. Local accounts stay open behind an OIDC provider. Link, challenge and code are stored only hashed, in global tables (compte_jeton, compte_defi), outside the SQL export.
The second factor by app
An administrator or organiser account can choose an authenticator app (TOTP, RFC 6238: six digits, a new code every 30 seconds) in place of the code received by e-mail. Nothing imposes it, administrators included, and no instance setting does. HR, stand-lead and reader accounts are not offered this choice yet: they keep signing in with the password followed by the code received by e-mail.
- Turn on: My account (the Account menu of the top bar; for an account holding only the RH right or a stand lead’s, the My account link on its page) shows a QR code and the key as text. The secret is only stored once a first valid code has been typed. Eight backup codes are then shown once: write them down away from the phone. A new series cancels all the previous ones.
- At sign-in the app replaces the code by e-mail: no mail is sent. It is still asked for when
AUTH_LOCAL_SECONDE_ETAPE=false, which only turns off the code by e-mail: an instance with no mail can therefore use it as the only second factor. A code works once (a code already used is refused), with a tolerance of one 30-second clock step (the server’s time). A backup code is typed in the same place. - Failures count like those of the code by e-mail: five tries per sign-in, then the instance’s sign-in lock; in addition, fifteen wrong codes in total on an account, from whatever address, block new sign-ins for
CONNEXION_DUREE_BLOCAGE(fifteen minutes by default); a right code resets that account to zero. This counter is held in memory: restarting the application resets it. Signing in correctly is never refused, however often. The sign-in journal records them like any failure, with the IP address and the time, never the code typed. - Forgot password: the link changes the password and nothing else. The second factor is still required at the next sign-in.
- Turning off the second factor, or generating new backup codes, asks for a recent sign-in (
AUTH_RECENT_WINDOW, ten minutes by default). - Every right can use it, a read-only account included: turning on one’s own second factor writes nothing in an edition. The route this opens (
/api/mon-compte/totp) is the only one the RH and stand lead rights gain; no other route of the administration opens to them. - An OIDC account has no second factor here: it is the provider’s.
- Encryption: the secret is encrypted at rest with
INSTANCE_SECRET_KEY, like the webhook secrets, and leaves in no export or dump. Without that key, turning it on is refused rather than storing the secret in clear; and the application refuses to start if a second factor exists while the key is missing or does not open its secret (what to do).
If you are the only administrator, turn it on keeping its backup codes, and remember that the configuration’s emergency account (see below) remains the last door.
Lost phone
- A backup code in place of the app’s code, then a new second factor in My account.
- Another administrator opens Settings › Accounts and chooses “Reset the second factor” on the account’s row (recent sign-in required); the action is in the action journal. The account then signs in with its password and a code by e-mail, and can turn on a new one.
- The emergency account of the configuration does the same reset when no other administrator is available.
- As a last resort, in the database, when none of these doors is open:
DELETE FROM compte_totp_secours WHERE compte_id = '<account id>'thenDELETE FROM compte_totp WHERE compte_id = '<account id>'(the id is read withSELECT id FROM compte WHERE lower(email) = lower('<address>')). Note the intervention: no journal line records it.
What the account protects
- Lockout: the form is locked by address like
admin's (CONNEXION_MAX_ECHECS), but the counter is finer. It counts per (IP address, account) pair at the form’s threshold, per address alone at ten times that threshold and per account, all addresses together, also at ten times that threshold. Behind a festival’s shared wifi, several people’s typos do not block everybody, but one password tried on many accounts, or many passwords on one account, meet a wall (ten addresses in the same window to lock an account: fifty tries perCONNEXION_DUREE_BLOCAGEwith default settings). A successful sign-in resets only the failures of its own pair. During a block the owner is refused too, even with the right password: the accepted price, lifted by itself when the block duration ends. - No hint: a response never says whether an address has an account, and code and link requests are limited per account.
- Sessions: deactivating an account cuts its session at the next request, and choosing a new password closes every session opened with the old one (the owner is told by mail). A session whose password changed, or whose account was deactivated then reactivated, is anonymous (
401): the session epoch (sessions_depuis) moves at each of these events. Every sign-in, successful or not, is in Settings › Sign-ins (IP address and time, never what was typed).
Never lock yourself out
Behind an OIDC provider, the configuration’s admin account is closed by default. Before connecting the provider, create your own administrator account and check that it opens the administration: otherwise, the day the provider stops answering, only the database is left. The full procedure (preparation, reopening with ADMIN_LOCAL_SECOURS=true, rereading the sign-in log) is in the emergency account. Lost password of the last administrator: same procedure.
A mistake, an omission? Fix this page on GitHub. (external site)