Skip to main content

Overview

The Ceboelha API uses a secure JWT-based authentication system with the following features:
  • Access & Refresh Token Pattern: Short-lived access tokens (15 minutes) with long-lived refresh tokens (7 days)
  • Token Rotation: Refresh tokens are automatically rotated on each use to prevent reuse attacks
  • HttpOnly Cookies: Tokens are stored in secure, HttpOnly cookies for enhanced security
  • Brute Force Protection: Account lockout after 5 failed login attempts for 15 minutes
  • Device Tracking: All sessions are tracked by device and IP address
  • Rate Limiting: All auth endpoints are rate-limited (5 requests per 15 minutes)

Security Features

Password Requirements

Passwords must meet the following criteria:
  • Minimum 8 characters
  • At least 1 uppercase letter
  • At least 1 lowercase letter
  • At least 1 number
  • At least 1 special character (!@#$%^&*…)
  • Not a common password

Token Storage

Tokens are automatically set as HttpOnly cookies:
  • accessToken: Access token cookie (15 minutes)
  • refreshToken: Refresh token cookie (7 days)
Important: You don’t need to manually handle tokens in the request body. The cookies are automatically sent with each request.

Account Lockout

After 5 failed login attempts, accounts are locked for 15 minutes. The system will inform users of remaining attempts after 3 failed tries.

Authentication Flow

  1. Register or Login to receive tokens via cookies
  2. Access Protected Routes - cookies are automatically included
  3. Refresh Token when the access token expires (before making requests)
  4. Logout to revoke tokens and clear cookies

Available Endpoints

Register

Create a new user account

Login

Authenticate existing user

Refresh Token

Renew access token

Logout

Revoke tokens and end session

Error Codes

All authentication endpoints may return the following error codes:
CodeStatusDescription
VALIDATION_ERROR400Invalid input data (e.g., weak password, invalid email)
UNAUTHORIZED401Invalid credentials or expired token
CONFLICT409Email already registered
RATE_LIMIT429Too many requests or account locked

Common Error Responses

Validation Error (400)

{
  "success": false,
  "error": "Validation failed",
  "code": "VALIDATION_ERROR",
  "message": "Senha deve ter no mínimo 8 caracteres"
}

Unauthorized (401)

{
  "success": false,
  "error": "Unauthorized",
  "code": "UNAUTHORIZED",
  "message": "E-mail ou senha inválidos"
}

Account Locked (429)

{
  "success": false,
  "error": "Rate limit exceeded",
  "code": "RATE_LIMIT",
  "message": "Conta bloqueada temporariamente. Tente novamente em 15 minutos."
}

Build docs developers (and LLMs) love