Tenant scope
A user can belong to more than one tenant. The active tenant decides which records they read and write, and permissions are checked for that tenant, so the same person can hold different roles in different tenants. Another tenant’s record ID answers exactly like a missing one. Confirm the active tenant before saving settings, connections, schemas, saved runs, or automations.Roles
Darpan seeds six permission groups. Two are Darpan-wide; the four tenant roles are assigned per tenant. Names are as the admin app shows them.
Darpan admins are users in either Darpan-wide group; the framework’s built-in
ADMIN group counts as a Super admin. A Darpan admin reaches every tenant as a tenant admin, with no membership to add. The admin app and every admin.* method need Super admin. A super admin adds or removes the Darpan admin and Super admin roles on a user’s page in the admin app; their own Super admin role cannot be removed there.
Session lifecycle
- Sign-in:
login#Sessionreturns a login-key token and also sets the HttpOnlydarpan_login_keycookie. Readauthenticatedin the result to know whether a session exists. - Lifetime: a web sign-in ends after 60 minutes with no request, and 24 hours after sign-in at the latest. Each request moves the idle end on.
authTokenExpiresInSecondsreports the 24-hour end, and the cookie expires then too. There is no refresh call: sign in again to get a new token. - Two-factor: when two-factor is on or required, a right password does not sign in on its own.
login#Sessionanswers with a challenge (twoFactorRequiredortwoFactorSetupRequired) instead of a token, andverify#SignInCodefinishes the sign-in with a code, a recovery code or a passkey assertion. See Two-factor. - Passkey alone: where passkeys are offered, the sign-in page asks for the username first and its field’s autofill offers saved passkeys, which need no password; Use a passkey or security key on the password step scopes the prompt to the typed username.
begin#PasskeyFirstSignInreturns the options and a one-use token, andfinish#PasskeyFirstSignInanswers as a completedverify#SignInCodedoes. A security key needs the username typed first; a passkey kept on the device needs none. Password plus code stays as the fallback, and an account that must change its password is asked to sign in with the password once. - CSRF bootstrap (browser):
GET /apps/darpan/csrfTokenrestores the session from the cookie when present and returns{"moquiSessionToken": "<token>", "authenticated": true|false}. Send the token in theX-CSRF-Tokenheader on laterPOST /rpc/jsoncalls. Header-token callers skip this step. - Sign-out:
logout#Sessionrevokes the token on the current request (header or cookie) and ends only that session.logout#AllSessionsrevokes every login key for the user, which signs them out on every device. - Password: a new password needs at least 12 characters, one number and one symbol, and cannot repeat one of the last five.
verify#OwnPasswordchecks the current password without changing anything.change#OwnPasswordchanges it for a signed-in user and revokes every other login key, CLI sign-ins included; the current session stays. When sign-in reportspasswordChangeRequired, usechange#ExpiredPassword, which needs no session; then sign in again. - Active tenant: the active tenant is stored as a preference on the user, not on the session. Switching tenant with
save#ActiveTenantchanges it for every session of that user, including other browser tabs. Give integrations their own user rather than sharing a login with a browser user.
Forgot password
Forgot password? appears under Sign In only when the instance can send email;get#PasswordResetStatus reports whether it can.
CLI access
CLI access is set per user, per tenant, and is off by default. A user asks for it in User settings under CLI sessions; a super admin approves or declines in the admin app. A grant can carry an end date and can be paused, unpaused, or revoked. Darpan admins, super admins included, use the CLI in every tenant without a grant. Setup steps: Set up the Darpan CLI.- Lifetime: every tenant CLI sign-in lasts 7 days, whatever the role, Darpan admins included. The admin CLI sign-in lasts 12 hours (see below).
- Sign-in:
darpan loginprints a code; the user approves it on Approve CLI (/cli-login) within 10 minutes. The password never goes through the terminal. With two-factor on, approving also takes a current code from the authenticator app or a passkey. - Every call is checked against the tenant it reaches. It is refused when access there has ended, is paused, or is revoked, or when the tenant sign-in is older than 7 days; run
darpan loginagain. - When a role requires two-factor and the user has not set it up, CLI calls are refused with “Two-factor is required for this account. Set it up in the Darpan app, then run darpan login again.”
- Revoke in CLI sessions ends one sign-in; a password change ends all of them.
- Admin CLI:
darpan-adminsigns in by browser approval. It prints a link and an 8-character code; the person opens the link in the Darpan app, types the code from the terminal, and approves with a fresh passkey or authenticator code. Only a super admin can approve an admin sign-in. It lasts 12 hours, is kept between commands until it ends ordarpan-admin logoutis run, and is the only CLI sign-in that can calladmin.*. A tenant CLI sign-in is refused there with ”… is not available to the Darpan CLI; use the app.” - Reach: a CLI sign-in can call only
/rpc/jsonand/rest/s1/graphql. On/rpc/jsonit reaches every tenant method the person’s role allows in the app (3.4.11 and later), and each method checks that role itself. A view-only member is refused a change by the method, as in the app. Out of reach: connection credentials (their saves and deletes, sharing, and any read that returns a password, token, key, webhook URL, username or certificate id), sign-in, two-factor, passkeys and CLI access, Shopify and Slack installs, everyadmin.*method, and the audit agent’s chat. Changing which endpoints a connection reads needs edit access (3.4.11 and later).
Two-factor
Two-factor adds an authenticator-app code (6 digits, a new one every 30 seconds) or a passkey after the password. A person can hold the app, up to ten passkeys, or both, and gets ten one-time recovery codes when the first factor goes on. Setup steps: Two-factor sign-in.- Dates are on the UTC calendar: a requirement dated for a day starts at 00:00 UTC. A super admin sets the date.
- Reminders: each person a dated requirement covers (a role, or everyone) who has no factor set up and has an email address gets a reminder when the date is set, again as the date nears, then weekly, at most one a day. They stop once a factor is on.
- A fresh code or passkey is asked for when approving a CLI sign-in, making new recovery codes, changing or turning off a factor, and on admin actions such as a config transfer export or a two-factor reset.
- Turning two-factor on or off, and an admin reset, end every other sign-in of the person, web and CLI. The tab that made the change stays signed in. Adding or removing a factor that is not the last ends nothing.
- The last factor of a person whose role requires two-factor cannot be removed.
- A password reset never turns two-factor off; it clears a code lock.
- A super admin resets a person’s two-factor from the person’s page in the admin app with Reset two-factor, giving a reason and their own code. It removes the app, passkeys and recovery codes and ends the person’s sessions and CLI keys.
- Passkeys are offered only where the Darpan instance has a passkey address configured and the browser supports them.
AI access
The audit agent answers only when it is on for the instance and the tenant, the user is a Tenant admin or Company editor there, and the user has AI access there. A super admin grants AI access per user, per tenant, in the admin app, for a period and with a spend limit, and can pause, unpause, or revoke it. Access pauses on its own when spend reaches the limit. Super admins have AI access in every tenant where the agent is on, with no per-user limit. A Tenant user or Company view only member is refused with “Only editors and tenant admins can talk to the agent.” See Audits.GraphQL agent keys
A tenant admin’s GraphQL agent key lasts at most 90 days, the default maximum. A key minted with no expiry gets the maximum, and a later expiry is refused. Each key records who minted it. Endpoint and key details: GraphQL API overview.Request fence
/rpc/json answers HTTP 403 for any method outside facade.*, admin.*, and gql.*, before dispatch. The framework’s /rest/login is closed.
Darpan signs people in only through login#Session and its two-factor step. HTTP Basic credentials, and a username and password sent as request parameters or inside a request body, are refused with HTTP 401 on every route, whether the password is right or not. API clients use a session or an API key.
Sensitive auth values
Examples use placeholders for usernames, passwords, session cookies, login keys, CSRF tokens, and other auth values.To add users and assign roles, see Manage users and access.