Open Enterprise
Browse topics
DocumentationIdentity and access

Local accounts

Local accounts let people sign in with an email address and password that the runtime stores. They need no identity provider, so a product can start with them and add customer SSO later. The same canonical user keeps its ID, memberships, roles, and application data when it later signs in through OIDC or SAML.

Local accounts are optional. A deployment without local_authentication needs no local key, SMTP relay, or operator credential.

Start without an identity provider

compose.local.yaml runs PostgreSQL, the runtime, a development mail inbox, and the example application.

  1. Start it:

    Shell
    docker compose -f compose.local.yaml up -d --build --wait
  2. Create the first owner of org_demo:

    Shell
    docker compose -f compose.local.yaml exec runtime enterprise-runtime enroll /app/config.yaml \
      --email owner@example.test --organization org_demo \
      --organization-name "Example Studio" --initial-owner

    The command prints a single-use enrollment_url. Treat it like a password. Add --send-email to send it to the address instead.

  3. Open the link, choose a password, and open the example application.

  4. Select Sign in with email, sign in, and choose Example Studio.

  5. Select Account security to change the password or email address, turn on two-step verification, end sessions, or link an SSO identity.

  6. Open the development inbox to read verification and reset messages.

The example runs in onboarding mode, so Create an account also works. A new customer confirms their email address, chooses a password, names a workspace, and becomes its owner.

npm run test:e2e:local runs this whole path in a browser.

Configure

YAML
local_authentication:
  connection_id: local
  organization_ids: [org_example]   # or all_organizations: true
  application_redirect_uris: [https://app.example.com/auth/callback]
  registration: closed              # public, invitation, or closed
  secret_key_env: LOCAL_AUTH_SECRET_KEY
  previous_secret_key_envs: []
  verification_minutes: 1440
  reset_minutes: 30
  enrollment_hours: 72
  branding:
    product_name: Example
    logo_url: https://app.example.com/logo.svg
    primary_color: "#2f5bd3"
  password:
    memory_kib: 19456
    iterations: 2
    parallelism: 1
    max_concurrent_hashes: 4
    blocklist_file: /etc/open-enterprise/blocked-passwords.txt
  email:
    from: Example <no-reply@example.com>
    smtp_host: smtp.example.com
    smtp_port: 587
    smtp_security: starttls         # starttls, tls, or none (development only)
    smtp_username_env: SMTP_USERNAME
    smtp_password_env: SMTP_PASSWORD
    timeout_seconds: 10
    max_attempts: 8
    retry_base_seconds: 30
    templates_dir: /etc/open-enterprise/mail

Applications start a local login with connection_id. organization_ids lists the organizations where local login may run. all_organizations: true includes organizations created later, such as those customers create through onboarding. Each organization's login policy still applies.

secret_key_env names a variable that holds 32 random bytes as unpadded base64url. enterprise-runtime keygen prints a suitable value on its key= line. The key seals TOTP seeds and the bodies of queued messages that carry links. Password hashes and recovery codes are one-way and do not use it.

Passwords use Argon2id with the parameters above, which follow the OWASP minimum. Outside development, memory_kib multiplied by iterations must be at least 38912, the cost of the OWASP profiles. Each hash holds memory_kib while it runs, and at most max_concurrent_hashes run at once. Passwords need at least 15 characters, may have up to 1024, and must not appear in the built-in or configured blocklist or contain the email address. The runtime does not impose composition rules or expiry.

Without email, registration must stay closed. Operators then enroll people and recover accounts with links they deliver themselves. Addresses stay unconfirmed, and the runtime never marks one confirmed without proof.

Registration

registration decides who may create an account.

Policy Who can register
public Anyone who confirms an email address.
invitation Someone with a valid organization invitation for the same address.
closed Nobody. Operators enroll accounts.

Registration asks only for an email address and an optional name. The runtime sends a link, and the person chooses a password after opening it. An attacker who registers someone else's address therefore never knows the password of the resulting account. Until the link is used the address stays unclaimed, and a verified registration or enrollment for the same address releases it. The response to a registration never says whether the address already has an account.

Onboarding for new customers

A product that lets customers sign up and create their own organization uses onboarding. The service needs organizations:create and created_organizations: true.

TypeScript
const started = await client.auth.onboarding.begin({
  connectionId: "local",
  redirectUri: "https://app.example.com/auth/callback",
  state,
  exchangeChallenge,
  signup: true,
});
// Redirect the browser to started.login_url. On the callback:
const issued = await client.auth.onboarding.exchange(code, verifier);
const created = await client.auth.onboarding.createOrganization({
  onboardingToken: issued.onboarding_token,
  id: "org_7f3a",
  name: "Acme",
  slug: "acme-7f3a",
});
// created.token is the owner's session in the new organization.

The token expires in ten minutes and is single-use. A verified address is required to create an organization. The organization, the owner membership, and the owner's session are created in one transaction. With created_organizations, the service may then act on the organizations it created with its other scopes. This includes member, login, and audit calls as well as advanced permission evaluation, resource search, diagnostics, inspection, and policy management. Every operation still requires its own service scope.

For multiple Fastify replicas, give each instance the same EXAMPLE_DATABASE_URL, EXAMPLE_SESSION_SECRET, public application origin and OE service identity. Every replica admits workspaces from the application's configuration or its shared enrollment table. Before calling OE to create a workspace, Fastify reserves an ID and a random slug in that table. If the response is lost, a replica can use organizations:read to confirm that OE created the matching workspace. The owner can then sign in again. Other organizations in the service credential's scope stay outside the application.

If you ran the earlier Fastify example, review the workspace IDs in its example_organizations table against your customer records. That table also contained workspaces imported during sign-in. Add verified customer IDs to ENTERPRISE_ORGANIZATION_IDS on every replica when upgrading. New signups populate example_workspace_enrollments automatically.

Returning users with multiple workspaces

Begin the same organization-independent flow with signup: false under a service with auth:login. After authentication, the exchange returns the user's active, service-accessible membership choices in issued.workspaces. Render their names and submit the selected ID to the application backend.

A login-only backend receives HTTP 403 if the user has no active membership in a workspace that both the service and the local deployment can serve. On success it receives the choices and a single-use token. Read the user profile from GET /v1/me with the selected tenant session. A backend with organizations:create and created_organizations: true also receives issued.user, including for a first-time signup with an empty workspace list.

TypeScript
const issued = await client.auth.onboarding.exchange(code, verifier);
const { token, session } = await client.auth.onboarding.enterWorkspace(selectedId, issued.onboarding_token);

Keep the proof server-side. Selection rechecks the service, the current membership, sign-in policy and directory state. A workspace that requires company SSO or stronger authentication can request a tenant-specific sign-in. The hosted example also shows operator-enrolled users their assigned workspaces by name.

Opening a tenant session records auth.login.succeeded in its audit history with the user, calling service, connection and authentication methods.

A personal workspace and a team workspace can have separate memberships for the same canonical user. The host owns business-record transfers. For a project move, authorize the operator in both workspaces, lock the project in its current workspace, and register its destination permissions before exposing the record there. Persist or retry cleanup of its old access and record the change in each tenant's audit history.

Invitation registration

Under invitation, pass the invitation token when the application starts the login:

TypeScript
await client.auth.begin({
  organizationId,
  connectionId: "local",
  redirectUri,
  state,
  exchangeChallenge,
  signup: true,
  invitationToken,
});

Set invitation_accept_url to the application entry such as https://app.example.com/invite. Present the recipient with the link returned by the invite API or let the SMTP worker send it. The address being registered must match the invitation. After exchange, call client.asSession(token).organizations.acceptInvitation(organizationId, invitationToken). Both the compact invitation-only starter and the public-signup starter implement this handoff.

Sign in

Applications start a local login exactly as they start an OIDC login, with POST /v1/auth/flows and the local connection_id. The browser goes to the runtime's sign-in page, and the application receives the usual exchange code. signup: true opens the registration page instead.

The runtime serves these pages under its public URL:

Path Purpose
/auth/local/login Sign in, then two-step verification when it is on
/auth/local/register Registration
/auth/local/verify Confirm an address and, for a registration, choose the password
/auth/local/forgot, /auth/local/reset Password reset
/auth/local/enroll Operator enrollment and first-owner setup
/account Account security pages

The pages need no JavaScript. Every form carries a CSRF token bound to a cookie, and the runtime checks the Origin and Sec-Fetch-Site headers. Single-use tokens move from the address bar into a short-lived cookie before the page renders. Cookies are HttpOnly, SameSite=Lax, and Secure when the public URL uses HTTPS. The login transaction is bound to the browser that started it, so a code cannot be completed in another browser.

Account pages

The application opens the account pages with a single-use link created from the user's runtime session:

TypeScript
const entry = await client
  .asSession(runtimeToken)
  .account.createEntry({ returnUrl: "https://app.example.com/" });
// Redirect the browser to entry.url within 60 seconds.

returnUrl must use an origin of application_redirect_uris. If the application sets a CSP form-action, it must include the runtime origin, because the form that requests the link redirects there.

People can change their password and email address, turn two-step verification on or off, create new recovery codes, end sessions, add a password sign-in to an SSO-only account, and link or remove SSO identities. Each sensitive change needs a sign-in from the last five minutes on the account pages. With two-step verification on, that confirmation needs the second factor too. SSO confirmation and identity linking request a new sign-in and verify its signed authentication time. A newly issued ID token from an older SSO session cannot confirm a sensitive change.

A password change or reset ends every other session. An email change takes effect when the new address opens its link, and the old address gets a notice. Disabling local credentials or removing an SSO identity ends sessions and OAuth grants created through that method. Removing an SSO identity reserves its mapping and rejects pending upstream logins through that method. Restoring it requires an explicit account link or reviewed operator migration and does not restore old sessions or tokens. Other sign-in methods of the account remain available.

Two-step verification

The runtime supports TOTP (RFC 6238, SHA-1, 6 digits, 30-second steps, one step of clock skew). People scan a QR code or type the setup key, then confirm with a code. They then get ten recovery codes, shown once and stored as hashes.

Each TOTP step and each recovery code works once, including under concurrent requests. A login fails after five wrong codes and starts again with the password. After 100 wrong codes in a row, the account's second factor locks, as NIST SP 800-63B allows, and even a correct code is refused. A correct code resets the count, and a password reset or an operator factor reset unlocks the factor.

Sessions record how the person signed in:

Sign-in amr acr
Password pwd urn:open-enterprise:acr:local:password
Password and TOTP pwd, otp, mfa urn:open-enterprise:acr:local:totp
Password and recovery code pwd, mfa, recovery_code urn:open-enterprise:acr:local:recovery-code

Permission rules that require mfa accept the last two. A recovery code is weaker evidence than an authenticator, so rules can tell them apart by acr or the recovery_code method.

An organization can require two-step verification for local sign-in with its login policy. Members without a factor then set one up before the sign-in finishes.

Organization login policy

Each organization has a local login policy:

local_login Effect
enabled Members may sign in with a local password.
recovery_only Only recovery owners may: active owners whose membership no directory manages.
disabled Nobody may; members use SSO.

Read and change it with GET and PUT /v1/organizations/{id}/login-policy, client.organizations.updateLoginPolicy, or the administration portal's Sign-in policy page. Changing it needs sso:write and the version you read; a concurrent change fails with a conflict. Sessions that no longer meet the policy stop working at once. To prevent a lockout, disabled is refused with a conflict when the person changing it signed in with a password, because that session would end, or when no active owner has a single sign-on identity to sign in with afterwards. Choose recovery_only in those cases, or sign in through SSO first.

When administration enforces SSO, employees use the customer connection and recovery owners can use the independent recovery connection. To admit external clients by local password, create a dedicated custom role such as external_client, set guest_role to that name with local_login: enabled, and invite those clients into the role. The guest exception uses the verified recipient for a pending invitation and the locally managed active membership after acceptance. Directory-managed staff and other roles continue to use SSO. The tenant's local MFA requirement applies. Grant access to each engagement using resource permissions separately.

The policy belongs to the organization, not the account. A person who belongs to two organizations keeps local access to one when the other turns local login off.

Email delivery

Messages go through a PostgreSQL outbox, so a challenge and its message are created together. A worker on each replica claims messages with a lease, sends them over SMTP, and retries temporary failures with exponential backoff from retry_base_seconds, capped at one hour. A permanent SMTP failure or max_attempts attempts ends delivery as failed. A message whose link expired, was used, or was replaced before delivery ends as expired, so a late message never carries a working stale link.

Operators list recent deliveries with GET /v1/operator/email-deliveries. The list shows the template, recipient domain, status, attempts, and last error, and never the body. oe_email_deliveries_total{outcome,template} counts sent, retried, and failed attempts.

Templates are plain text. Put <template>.txt files in templates_dir to replace the built-in ones. The first line must be Subject: ..., and the body follows. Placeholders such as {{product}}, {{email}}, {{link}}, and {{minutes}} are filled in. The built-in templates in crates/provider-local-auth/src/mail.rs list the names and the placeholders each one uses.

scripts/mail-fixture.mjs is the development inbox. It accepts plain SMTP on port 2525 and shows messages at port 8025, and POST /outage makes it answer with a temporary failure. It has no authentication.

Operators

Operators enroll people, recover accounts, disable accounts, and run identity migrations. The CLI acts as the operator cli with every scope, because whoever runs it holds the database credential:

Shell
enterprise-runtime enroll <config> --email E --organization O [--organization-name N] [--role R] [--initial-owner] [--send-email]
enterprise-runtime account <config> show|disable|enable|recover|reset-mfa|disable-local|enable-local --user U [--reset-factors] [--send-email]
enterprise-runtime identity-migration <config> plan --file mapping.json [--allow-shared-users] | run --id M | status --id M

An HTTP API under /v1/operator does the same for automation. Configure an operator credential:

YAML
operators:
  - id: operations
    key_hash_env: OPERATOR_KEY_SHA256
    scopes: [accounts:read, accounts:manage, identities:migrate, deliveries:read]

Operator credentials are separate from service credentials and are not limited to organizations. Give them only to people who run the deployment. Every operator action is audited with the operator ID.

--initial-owner creates the organization when it does not exist and makes the enrolled person its owner. Nobody becomes an owner by being the first visitor.

account disable stops every sign-in method of the user, local and linked, in every organization, and ends their sessions and pending exchanges. account recover issues a single-use password link and, with --reset-factors, removes the authenticator and recovery codes.

Import existing users

POST /v1/operator/user-imports, with the accounts:manage scope, brings users over from an application's own user table. Each request takes up to 500 users. Review the result for every row before running a sign-in migration.

JSON
{
  "mode": "local_account",
  "users": [
    {
      "external_id": "app-user-17",
      "email": "ada@example.com",
      "display_name": "Ada Lovelace",
      "email_verified": true,
      "password_hash": "$argon2id$v=19$m=19456,t=2,p=1$...",
      "memberships": [{ "organization_id": "org_acme", "role": "member" }]
    }
  ]
}

external_id is the application's own stable user ID. Use "mode": "identity_only" for applications that keep their current login or use OIDC or SAML. This mode creates the canonical profile and requested memberships, accepts no password hashes, and works with local authentication disabled. When you omit mode, OE uses local_account if local authentication is configured and identity_only otherwise.

An identity-only import matches an existing user by external_id. An email already on a different profile requires operator reconciliation. Before the user's first SSO login, link the immutable provider subject to the imported canonical ID. Existing SaaS walkthrough

The local-account mode finds users in this order.

  1. The user with the same external_id.
  2. The only user without an external_id whose local account, or profile when there is no local account, has the same email address. The import sets the external_id.
  3. Otherwise, a new user, with a local account when the row has an email address.

An address that belongs to a user with a different external_id, or to several users, fails with conflict. Re-running an import is safe: matched users keep their existing password and their existing memberships and roles. An import can't grant the owner role; use --initial-owner enrollment for that.

password_hash accepts Argon2id, Argon2i or Argon2d PHC strings with at most 64 MiB of memory, 10 passes and 4 lanes. It also accepts Django's pbkdf2_sha256$iterations$salt$base64_digest format with 1 to 1,200,000 iterations, a salt of 1 to 128 bytes and a 32-byte digest. Verification uses the same bounded worker pool as every other password sign-in. The first successful sign-in replaces the imported hash with an Argon2id hash at the deployment's cost. The same happens to any stored hash after the deployment's cost changes. For other formats or costs outside these limits, use password recovery. Without email_verified, the address stays unverified until the person verifies it.

The response lists one result per user, in request order, with the user ID and outcome (created, matched_external_id or matched_email), or an error. Each import is audited as account.imported.

Throttling

Limits are counted in PostgreSQL, so they hold across replicas. A successful password sign-in doesn't count, so signing in often doesn't lock anyone out. Once a password limit is reached, even the right password is refused until the window ends.

Limit Value
Failed password attempts for one address from one client 10 per 15 minutes
Failed password attempts from one client 100 per 15 minutes
Second-factor attempts for one account 10 per 15 minutes
Second-factor attempts in one login 5
Consecutive wrong second-factor codes for one account 100, then the factor locks
Registrations from one client 10 per hour
Registration and reset requests for one address 3 per hour
Reset requests from one client 20 per hour
Link submissions from one client 30 per 15 minutes
Messages to one recipient 10 per hour
Confirmations on the account pages for one account 10 per 15 minutes

The client is the TCP peer, or the address from X-Forwarded-For when the peer is in server.trusted_proxies. The runtime reads that header from the nearest hop back and stops at the first hop outside the trusted proxies or the first entry it cannot parse. Entries may carry a port, as in 203.0.113.7:51234 or [2001:db8::7]:51234. Limits count an IPv6 client by its /64 network, because one host often holds a whole /64. A throttled request gets a "Too many attempts" page with status 429, whether or not the address has an account. Throttles are checked before the password, so the page reveals nothing about the account.

Keys, rotation, and backups

Rotate the local key as you rotate other master keys:

  1. Set a new key in secret_key_env and move the old variable name to previous_secret_key_envs.
  2. Restart the replicas.
  3. Run enterprise-runtime reencrypt <config> to reseal TOTP seeds and queued messages.
  4. Remove the old key once reencrypt reports nothing left.

A backup restores working accounts and two-step verification only together with every key that sealed its TOTP seeds. See backup and restore.

Reference measurements

Measured on November 11, 2026, with compose.local.yaml on an Apple M3 Pro (11 cores) under Docker Desktop, using the default password parameters.

Measure Result
Container start to /readyz 200, schema current 0.8 s
Runtime memory at idle 10 MiB
Runtime memory, peak during npm run test:e2e:local 105 MiB
One Argon2id verification 11 ms median, 12 ms p95
Verifications per second with max_concurrent_hashes: 4 about 260

Hashing holds about 19 MiB per running hash, so four concurrent hashes add about 76 MiB. Size max_concurrent_hashes and the memory limit together. A request waits up to 10 seconds for a free slot, then fails as temporarily unavailable instead of exceeding the limit. The throttles in this guide apply in addition to that ceiling.

Move to SSO and back

The provider-migration runbook covers linking identities, bulk migrations, enforcement, and returning to local sign-in.

Limitations

  • TOTP is the only second factor; there is no WebAuthn yet.
  • Closing the account pages ends the account-page session in the browser but does not revoke it on the server; it expires after 30 minutes.
  • A newly created organization can use the advanced permissions API under its creator’s scoped service credential. An operator can enable the customer administration portal separately.
  • Email is the only delivery channel.

Search documentation