Authentication

Register

POST /api/v1/auth/register
{
  "name": "Jane Smith",
  "email": "jane@company.com",
  "password": "SecurePass123"  // min 8 chars, 1 uppercase, 1 number
}

Login

POST /api/v1/auth/login
{ "email": "jane@company.com", "password": "SecurePass123" }

// Sets httpOnly cookies:
// access_token  (15 min)
// refresh_token (30 days)

Refresh Token

POST /api/v1/auth/refresh
// Uses refresh_token cookie automatically
// Returns new access_token

Forgot Password

POST /api/v1/auth/forgot-password
{ "email": "jane@company.com" }
// Sends reset email

Reset Password

POST /api/v1/auth/reset-password
{ "token": "from-email-link", "password": "NewSecurePass123" }

OAuth (Google / GitHub)

Redirect the user to:

/api/v1/auth/oauth/google
/api/v1/auth/oauth/github

After authorization, the user is redirected to /dashboard with cookies set.

Token Security

  • Access tokens expire after 15 minutes
  • Refresh tokens are rotated on every use (token rotation)
  • All tokens are httpOnly cookies — not accessible to JavaScript
  • Logging out deletes the session from the database