Skip to content

Authentication

Stowaway uses NextAuth.js for authentication, providing secure session-based authentication.

Create a new user account.

POST /api/auth/register
{
"name": "John Doe",
"email": "john@example.com",
"password": "securepassword123",
"confirmPassword": "securepassword123"
}
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"email": "john@example.com",
"role": "USER"
}
FieldRules
nameOptional, max 100 characters
emailRequired, valid email format
passwordRequired, min 8 characters
confirmPasswordMust match password

Authentication is handled through NextAuth.js endpoints.

POST /api/auth/callback/credentials
{
"email": "john@example.com",
"password": "securepassword123"
}

On success, a session cookie is set and user is redirected.


Get current session information.

GET /api/auth/session
{
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"email": "john@example.com",
"role": "USER"
},
"expires": "2024-02-15T12:00:00.000Z"
}

End the current session.

POST /api/auth/signout

Standard users can:

  • View, create, edit, delete their own items
  • Manage their own categories and locations
  • Export/import their own data

Administrators have all USER permissions plus:

  • Access to all users’ data
  • User management (future feature)

Info: First User The first user to register automatically becomes an ADMIN.


  • Passwords are hashed using bcrypt with 12 rounds
  • Passwords must be at least 8 characters
  • No password is ever stored in plain text

  • Sessions use JWT tokens
  • Tokens are encrypted with AUTH_SECRET
  • Sessions expire after inactivity (configurable)
  • CSRF protection is enabled by default