Skip to content

Login and MFA ​

Covers the login flow, password policy, second-factor verification and password recovery.

Login flow ​

  1. Submit username and password, with an optional captcha
  2. The server verifies the password and lock state, then issues access and refresh tokens
  3. Accounts with MFA enabled must complete a second factor before tokens become valid
  4. Refresh tokens rotate: each refresh revokes the old token

Login

Password policy ​

SettingDefaultDescription
Minimum lengthFrom security config12+ recommended in production
ComplexityUpper, lower, digit, symbolChanges are rejected if the policy fails
Failure lockThreshold-basedLogin is refused while locked

MFA verification ​

When enabled, step one returns a challenge instead of tokens. After the user submits a TOTP code, the server atomically consumes the challenge and issues tokens.

  • TOTP secrets are encrypted at rest, with legacy plaintext still readable
  • Challenge consumption is serialized with a cache lock to prevent replay
  • Disabling MFA requires password re-verification

Password recovery ​

  1. The user submits a registered email. The API always returns the same generic success body to avoid account enumeration.
  2. The token is persisted first, and the delivery job is enqueued to the emails queue.
  3. worker sends the mail. Failures land in the failed job table for manual replay.
  4. The reset link is single-use.

WARNING

Keep SECURITY_RESET_DEV_RETURN_TOKEN=false in production. Plaintext token echo is only for local environments without SMTP.

Next steps ​