Overview
KAIU uses JWT (JSON Web Tokens) for authenticating admin users. Public endpoints (products, orders, tracking) do not require authentication, but admin endpoints require a valid JWT token.Login Endpoint
Authentication is only required for admin dashboard endpoints (
/api/admin/*). Public-facing endpoints do not require authentication.POST /api/admin/login
Authenticates a user and returns a JWT token. Request BodyUser’s email address (used as username)
User’s password (hashed with bcrypt)
Indicates if login was successful
JWT token valid for 24 hours
Example Request
Example Response
Using JWT Tokens
Once authenticated, include the JWT token in theAuthorization header for subsequent requests to admin endpoints:
JWT Token Structure
The JWT token contains the following claims:Token Expiration
Tokens expire after 24 hours. After expiration, users must log in again to obtain a new token.Security Configuration
The JWT secret is configured via theJWT_SECRET environment variable. The API uses bcrypt for password hashing with automatic salt generation.
Role-Based Access Control
The API supports the following user roles:| Role | Access Level |
|---|---|
ADMIN | Full access to all admin endpoints |
WAREHOUSE | Access to inventory and fulfillment endpoints |
SUPPORT | Access to order viewing and customer support endpoints |
CUSTOMER | No admin access (public endpoints only) |
Error Responses
400 Bad Request
401 Unauthorized
500 Internal Server Error
Security Features
- Password hashing: bcrypt with automatic salt generation
- Timing attack protection: 1-second delay on failed login attempts
- Case-insensitive email: Emails are normalized to lowercase
- Token expiration: 24-hour token lifetime