63 lines
1.2 KiB
Markdown
63 lines
1.2 KiB
Markdown
# Authentication
|
|
|
|
JWT-based authentication system for the Letzshop Import API.
|
|
|
|
## Overview
|
|
|
|
The API uses JSON Web Tokens (JWT) for authentication. Users must register, login to receive a token, then include the token in subsequent requests.
|
|
|
|
## Authentication Flow
|
|
|
|
1. **Register** - Create a new user account
|
|
2. **Login** - Authenticate and receive JWT token
|
|
3. **Use Token** - Include token in API requests
|
|
|
|
## Endpoints
|
|
|
|
### Register User
|
|
```http
|
|
POST /api/v1/auth/register
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"email": "user@example.com",
|
|
"username": "testuser",
|
|
"password": "securepassword123"
|
|
}
|
|
```
|
|
|
|
### Login
|
|
```http
|
|
POST /api/v1/auth/login
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"username": "testuser",
|
|
"password": "securepassword123"
|
|
}
|
|
```
|
|
|
|
Response:
|
|
```json
|
|
{
|
|
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
|
|
"token_type": "bearer",
|
|
"expires_in": 86400
|
|
}
|
|
```
|
|
|
|
## Using Authentication
|
|
|
|
Include the JWT token in the Authorization header:
|
|
|
|
```http
|
|
GET /api/v1/product
|
|
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
|
|
```
|
|
|
|
## User Roles
|
|
|
|
- **User** - Basic access to own resources
|
|
- **Admin** - Full system access
|
|
|
|
*This documentation is under development.* |