How DrootERP protects interactive sign-in: TOTP two-step sign-in (MFA), the sign-in policy, and single sign-on (SSO) through OpenID Connect. API keys and OAuth apps never sign in with a password, so none of this applies to them.
For Administrators
Two-Step Sign-In
After their password, a person types a 6-digit code from an authenticator app (Google Authenticator, Microsoft
Authenticator, 1Password, Authy and others). Anyone can turn it on under user menu › Sign-In Security
(/me/security): scan the QR code (or type the key), type a code, then save the ten recovery codes. Each recovery
code signs in once when the phone is lost; with three or fewer left, the person is sent to create new ones.
On the same page a person can move to a new phone (with a code from the old one), create new recovery codes, or turn two-step sign-in off (only when the policy does not require it).
Lost phone and recovery codes: Setup › Access › Users › the person's ⋯ menu › Reset Two-Step Sign-In. It
is audited (mfa-reset). When the policy requires two-step sign-in, their next sign-in sets it up again.
Sign-In Policy
Setup › Access › Sign-In Policy (needs users.admin):
| Who Must Use It | Meaning |
|---|---|
| Optional | Nobody is asked; anyone may turn it on. |
| Administrators | People whose role grants everything or user administration. The recommended minimum. |
| Chosen Roles | People holding any of the chosen roles (any company, including dated assignments). |
| Everyone | Everybody who signs in, except integration users. |
Days To Set It Up (0–90, default 7): until then people see the set-up screen at sign-in with Remind Me Later; afterwards they cannot continue without setting it up. The period restarts whenever the requirement widens.
The page also shows, read-only, the session and password rules the server runs with: SESSION_MAX_DAYS,
SESSION_IDLE_HOURS, PASSWORD_MIN_LENGTH and the lockout (5 wrong tries lock for 1 minute, doubling to 1 hour).
Single Sign-On (OpenID Connect)
Register DrootERP at your identity provider (Microsoft Entra ID, Google Workspace, Okta, Keycloak and others) as a
web application with the redirect URI https://<your web app address>/sso/callback, scopes openid email profile.
Then on the Sign-In Policy page, Add Provider:
- Discovery URL: the provider's
/.well-known/openid-configuration(https). - Client ID and Client Secret: the secret is stored encrypted in the connector secret store
(
sso-<key>) and never shown again. - Email Domains: people whose email ends in one of them see Continue With <provider> on the sign-in page. A domain belongs to one provider.
- Provider Confirms Two-Step Sign-In: tick only when the provider already asks for a second factor; then people signing in through it are not asked for a DrootERP code too.
- Create Accounts On First Sign-In: off by default. When off, only people you already added can sign in; matching is
by the email the provider confirmed (
email_verified). When on, a new account gets the chosen role (or none).
Require Single Sign-On For These Domains stops password sign-in for people of those domains. Administrators keep password plus two-step sign-in so you can still get in when the provider is down.
The web app address (Setup › Go-Live, step 1, or PUBLIC_APP_URL) must be set: the redirect URI is built from it.
Single Sign-On (SAML 2.0)
For identity providers that speak SAML (ADFS, Okta, Ping, Entra ID). On the Sign-In Policy page, Add SAML Provider: paste the identity provider's metadata XML (its entity ID, sign-in URL and signing certificate are read from it) or type them, and give the email domains it signs in. Give the identity provider this application's names:
- Entity ID (audience):
<web app>/sso/saml/<key> - Reply URL (ACS):
<web app>/sso/saml/acs(HTTP-POST binding) - Metadata:
<web app>/auth/saml/<key>/metadata
Email Attribute names the attribute holding the email (empty: the NameID). Role Rules, one per line,
attribute = value -> role @ company, give the person that role in that company and the companies under it; each
sign-in adds the roles that now match and revokes those that no longer do (assignments made by hand are never touched).
Create Accounts On First Sign-In and Provider Confirms Two-Step Sign-In work as for OpenID Connect. Encrypted
assertions are not accepted: switch assertion encryption off at the identity provider (the connection is TLS).
User Provisioning (SCIM 2.0)
Add Directory on the Sign-In Policy page issues a bearer token, shown once (the refresh button issues a new one).
Give the identity provider <API address>/scim/v2 and the token. It creates users (an existing account with the same
email is adopted), updates names, switches people off (active: false, or DELETE), and keeps groups. Group Rules,
group -> role @ company, map membership to roles the same way as SAML role rules. A directory sees only the users it
provisioned or adopted.
Go-Live
The checklist's Administrators Use Two-Step Sign-In passes when every administrator has it on, or single sign-on is enforced; otherwise it warns. Step 1 links the administrator to set it up.
For Developers
Sign-in flow. POST /auth/login checks the password. Then: enrolled → { mfa: "verify" } and a 5-minute ticket;
not enrolled but required → { mfa: "enrol", skippable, deadline } and a 15-minute ticket; otherwise the session as
before. POST /auth/mfa/verify { code } (a TOTP or a recovery code) finishes it. Wrong codes count against the same
per-account lockout and per-IP window as passwords. A ticket carries the session version, so a password change or
"Sign Out Everywhere" kills it.
| Endpoint | Who | What |
|---|---|---|
POST /auth/mfa/verify |
ticket | second step |
POST /auth/mfa/skip |
enrol ticket | Remind Me Later (grace period only) |
GET /auth/mfa |
signed in | status and requirement |
POST /auth/mfa/enrol/start |
ticket or signed in | new pending secret, otpauth URL, QR matrix (needs code when re-enrolling) |
POST /auth/mfa/enrol/confirm |
ticket or signed in | switches on, answers ten recovery codes (signs in with a ticket) |
POST /auth/mfa/recovery-codes |
signed in + code | ten new codes |
POST /auth/mfa/disable |
signed in + code | off (422 mfa_required under the policy) |
POST /api/admin/users/:id/mfa/reset |
users.admin |
reset, grant-limited, audited |
GET/PUT /api/admin/security/sign-in-policy |
users.admin |
policy |
PUT/DELETE /api/admin/security/sso-providers/:key |
users.admin |
SSO providers |
POST /auth/sso/discover, /auth/sso/start, /auth/sso/callback |
public | SSO sign-in |
Step-up (POST /auth/step-up, before releasing a payment or changing roles) asks an enrolled user for code
instead of the password; others keep using the password.
OIDC. Authorization code with PKCE (S256), a random state (single use, 10 minutes) and nonce. The ID token is
verified with the provider's JWKS (RS256, PS256 or ES256; keys refetched once when a kid is unknown): issuer,
audience (the client id), expiry (60 s leeway) and nonce. Only a verified email of one of the provider's domains signs
in. The shell's /sso/callback page posts the code and state to the kernel, which answers JSON (the shell proxy does not
follow redirects).
SAML. SP-initiated: POST /auth/saml/start stores the AuthnRequest id (single use, 10 minutes) and answers the
HTTP-Redirect URL (RelayState is the request id). The identity provider posts the Response to the shell's
/sso/saml/acs, which hands it to POST /auth/saml/acs server to server and sends the browser to
/sso/callback?saml=<code>; the callback page posts { saml } to /auth/sso/callback, which redeems the one-time code
(2 minutes) and continues exactly as an OIDC sign-in (two-step sign-in, lockout, audit). The Response is checked by
platform/identity/sso/saml-verify.ts with an in-house XML reader (no DTDs or entities) and exclusive C14N
(xml.ts): an enveloped XML Signature over the Response or its one Assertion, verified with the configured
certificate only (RSA-SHA256/512, ECDSA-SHA256; SHA-1 refused); the Reference must name the element holding the
signature, IDs must be unique and there must be exactly one Assertion, a child of the Response (signature wrapping).
Then status, Destination, issuer, InResponseTo, bearer SubjectConfirmationData (Recipient, NotOnOrAfter),
Conditions (NotBefore, NotOnOrAfter, 90 s skew) and every AudienceRestriction. Its tests run against fixtures
signed by another implementation (lxml and the cryptography package), so the canonical form is not only checked
against itself.
SCIM. /scim/v2/ServiceProviderConfig, /ResourceTypes, /Schemas, /Users and /Groups (GET with
filter=<attribute> eq "<value>", startIndex, count; POST; PUT; PATCH with Operations; DELETE), content type
application/scim+json, errors in the SCIM error shape. Public routes: each call proves its directory with the bearer
token (stored as a SHA-256 hash). Writes run as the system actor scim:<directory> and are audited.
| Endpoint | Who | What |
|---|---|---|
PUT/DELETE /api/admin/security/saml-providers/:key |
users.admin |
SAML providers |
PUT/DELETE /api/admin/security/scim-directories/:key |
users.admin |
SCIM directories (rotate: true issues a new token) |
GET /auth/saml/:key/metadata, POST /auth/saml/start, POST /auth/saml/acs |
public | SAML sign-in |
/scim/v2/* |
directory token | provisioning |
Designed, Not Built Yet
Passkeys (WebAuthn)
A second factor and, later, a password replacement. Plan:
- Collection
user_passkeys(credentialId, COSE public key, sign counter, transports, name, created/last used). - Registration:
POST /auth/passkeys/options(challenge in a 5-minute signed ticket,rp.id= web app host,userVerification: "preferred", exclude existing credentials) → browsernavigator.credentials.create→POST /auth/passkeysverifies the attestation (noneaccepted;packedself-attestation ok), stores the key. - Sign-in: the verify ticket also offers passkeys;
navigator.credentials.get→ verify the assertion (ES256/RS256 via node:crypto, origin and rpId hash, counter increase). Counts as the second factor, and as step-up. - Needs a CBOR decoder (~150 lines, no dependency) and the web app's exact origin; deferred until a customer asks.