Password & login security

Enforce password rules, prevent password reuse, lock accounts after failed logins and rate-limit sensitive user endpoints.

Password policy

Password rules for users and identities live in the configuration module, under the user and identity modules:

Terminal
curl -X PUT https://api.example.com/api/config/user \
  -H "Authorization: IDENTITY <token>" -H "Content-Type: application/json" \
  -d '{"password": {"minLength": 10, "minLowercase": 1, "minUppercase": 1, "minNumber": 1, "minSpecialCharacter": 1}}'
RuleDescription
minLengthMinimum number of characters.
minLowercaseMinimum lowercase letters.
minUppercaseMinimum uppercase letters.
minNumberMinimum digits.
minSpecialCharacterMinimum special characters.

Passwords that break the rules are rejected when an account is created or its password changes:

JSON
{"message": ".password must NOT have fewer than 10 characters", "error": "validation failed", "statusCode": 400}

Password history

Prevent people from reusing their recent passwords:

OptionDefault
--passport-identity-password-history-limit0 (off)
--passport-user-password-history-limit0 (off)

With a limit of 5, a new password can't be any of the last five.

Lockout after failed logins

OptionDefaultDescription
--passport-identity-failed-login-attempt-limit0 (off)Failed logins before identities are blocked.
--passport-identity-block-duration-after-failed-login-attempts0Minutes the block lasts.
--passport-user-failed-login-attempt-limit0 (off)Failed logins before users are blocked.
--passport-user-block-duration-after-failed-login-attempts0Minutes the block lasts.

For example, --passport-user-failed-login-attempt-limit=5 --passport-user-block-duration-after-failed-login-attempts=15 blocks a user for 15 minutes after five wrong passwords.

Rate limits

User endpoints that attackers like to hammer have their own rate limits, set in the user configuration:

JSON
{
  "rateLimits": {
    "login": {"limit": 10, "ttl": 60},
    "forgotPassword": {"limit": 5, "ttl": 300},
    "providerVerification": {"limit": 5, "ttl": 300},
    "refreshToken": {"limit": 30, "ttl": 60},
    "createUser": {"limit": 20, "ttl": 60}
  }
}

limit is the number of requests allowed within ttl seconds.

KeyApplies to
loginUser login (/passport/login) and passwordless login.
forgotPasswordPassword reset start and verify.
providerVerificationEmail and phone verification.
refreshTokenUser session refresh.
createUserPOST /passport/user.

For your own HTTP functions, use the trigger's rateLimit option.

Account and instance limits

OptionEffect
--passport-user-limitMaximum number of users.
--passport-identity-limitMaximum number of identities.
--passport-user-verification-code-expires-inLifetime of verification codes in seconds (default 300).

Checklist

  • Change the default identity's password, or remove the default identity.
  • Turn on two-factor authentication for identities with full access.
  • Set a password policy for users and identities.
  • Enable lockout and rate limits before you open sign-up to the public.
  • Keep access tokens short-lived and use refresh tokens.
  • Serve the API over HTTPS only.
  • Review identities, API keys and refresh tokens regularly, and remove what's unused.