ForkFit Docs

Authentication & Sessions

Deep dive into ForkFit session-based authentication model, token structure, and OTP validation.

Authentication & Sessions

ForkFit employs a secure, stateless bearer-token session model. Upon signing in, client apps receive an access token that must be presented in the Authorization header of all protected requests.


Authorization Header

All protected resources expect an Authorization header in the following format:

Authorization: Bearer <your_session_token>

Missing or Invalid Token

If the token is missing, expired, or revoked, the server replies with a 401 Unauthorized status.


Token Lifecycle

  1. Generation: Created during /auth/signin or successful OAuth callbacks.
  2. TTL (Time to Live): Configured via the SESSION_TTL_SECONDS environment variable (defaults to 30 days).
  3. Storage: Access tokens are stored on the server as active sessions in the user_sessions database table, enabling real-time audits and revocation.
  4. Revocation: A user can delete specific session IDs, or revoke all active sessions (/auth/signout-all).

One-Time Passwords (OTP)

Certain operations (such as email verification and resetting passwords) require a temporary 6-digit verification code:

  • OTP Lifespan: Configured via OTP_TTL_SECONDS (defaults to 10 minutes).
  • Max Attempts: Users are allowed up to 5 attempts to input the correct OTP before the code is permanently invalidated.

On this page