SuperTokens Docs

website·Indexed 35 days ago

https://supertokens.com/docs

An open-source authentication provider that gives developers control over user data and the login experience. Documentation covers core authentication, session verification, user roles and permissions, and the Additional Verification suite including MFA (TOTP, WebAuthn/Passkeys, Email/SMS OTP), email verification, and attack protection.

Tokens
378.7K
Snippets
1.2K
Records
1.7K
Agent score
67%

What's inside SuperTokens

  1. Overview of email delivery in SuperTokens

    Email delivery is managed independently by the recipes that generate the messages. The following recipes have their own email delivery configurations:

    • EmailPassword: For password resets.
    • EmailVerification: For email verification codes and links.
    • Passwordless: For email codes and links.
    • WebAuthn: For account-recovery emails.

    Note: The AccountLinking recipe does not configure email delivery.

  2. Overview of SuperTokens authorization data management

    SuperTokens provides two ways to handle authorization data. Session Claims are the recommended approach as they provide built-in validation, automatic refresh mechanisms, and graceful failure handling. The Access Token Payload is a simpler, lightweight method for checking static data but lacks automatic validation and refresh capabilities.

    Important: Frontend claim checks are for user experience only. All protected APIs must verify the session and enforce claim validators on the backend to prevent unauthorized access.

  3. Overview of SuperTokens Multi-Tenancy for Enterprise

    SuperTokens provides enterprise authentication through a multi-tenancy feature. Tenants act as isolated user groups, ensuring that users can only access data specific to their tenant. This architecture allows for separate databases per tenant, isolated user pools (where the same email can be used across different tenants as separate accounts), and the ability to configure unique login methods (e.g., one tenant using email/password and another using SSO/SAML) on a per-tenant basis.
  4. Overview of Client Credentials Flow for M2M Authentication

    The Client Credentials Flow is used for machine-to-machine (M2M) authentication where a service (Service A) needs to communicate with another service (Service B) without user intervention.

    The sequence is as follows:

    1. Service A provides credentials to the Authorization Server to obtain an OAuth2 Access Token.
    2. The Authorization Server returns the OAuth2 Access Token.
    3. Service A uses this token to request resources from Service B.
    4. Service B validates the token.
    5. If valid, Service B returns the requested resource.
  5. Overview of SuperTokens Passwordless Authentication

    The Passwordless recipe allows users to authenticate using generated credentials such as Magic Links or One-Time Passwords (OTP) instead of traditional passwords. Developers can choose between using the SuperTokens Pre-Built UI for a fast setup or implementing a custom user interface using the provided SDKs.
  6. Overview of SuperTokens Multi-Factor Authentication (MFA)

    SuperTokens provides Multi-Factor Authentication (MFA) to secure applications by requiring users to verify their identity through multiple credentials. Supported MFA factors include:

    • Email or SMS One-Time Password (OTP)
    • Time-based One-Time Password (TOTP)
    • WebAuthn or Passkeys

    Key capabilities include 'step-up authentication', which allows developers to require an additional challenge for specific sensitive routes or actions. MFA is available for managed SuperTokens deployments.

  7. Overview of SuperTokens Tenant Discovery

    Tenant discovery automatically routes users to the appropriate tenant based on the domain of their email address (e.g., user@company.com is routed to the company tenant). It includes built-in protection against popular email providers and falls back to the public tenant when necessary.

    Important Security Warning: Tenant discovery is for routing, not authorization. An email domain does not prove ownership or membership. After authentication, you must verify the user's membership in the discovered tenant and derive the tenant from trusted session data for every business-data access.

  8. Overview of SuperTokens session authorization methods

    SuperTokens supports two methods for authorizing requests. The choice of method is controlled by the backend, but it follows a preference set in the frontend configuration via the st-auth-mode header.

    • Cookie based: Default for web SDKs. Uses HttpOnly cookies to prevent token theft via XSS. Recommended for browsers.
    • Header based: Default for mobile SDKs. Uses the Authorization header with a Bearer auth-scheme. Preferred for mobile environments due to unreliable cookie implementations and easier integration with API gateways.
  9. Overview of SuperTokens CAPTCHA plugin

    The SuperTokens CAPTCHA plugin allows developers to add CAPTCHA validation to authentication flows. It currently supports React and NodeJS SDKs. Supported providers include Google reCAPTCHA v2, Google reCAPTCHA v3, and Cloudflare Turnstile.
  10. Overview of Step-up Authentication in SuperTokens

    Step-up authentication requires users to complete an authentication challenge before navigating to a specific page or performing a sensitive action. It can be implemented as a full-page navigation or as a popup on the current page.

    Supported authentication factors include:

    • TOTP
    • WebAuthn/Passkeys
    • Password (custom UI only)
    • Email or SMS OTP

    Note: Step-up authentication is currently not supported if you are using OAuth2 in your configuration.

  11. Overview of SuperTokens User Roles

    SuperTokens provides a User Roles feature that allows developers to implement granular authorization control. This system enables the creation of roles and permissions, which can be assigned to users to limit access to specific application features or data based on defined application logic.
  12. Overview of SuperTokens password hashing

    SuperTokens supports two password hashing algorithms: BCrypt and Argon2. While Argon2 is recommended per current best practices, BCrypt is used by default because Argon2 requires hardware-specific configuration.

    Changing the hashing algorithm only affects new users who sign up; existing passwords remain compatible with the algorithm used at the time of their creation. The target performance metric is approximately 300 milliseconds per hash.