Authentication¶
This guide covers the authentication mechanisms used in the NSGG Backend API.
JWT Authentication¶
The API uses JSON Web Tokens (JWT) for authentication. Each authenticated request must include a valid JWT token in the Authorization header.
Obtaining Tokens¶
Request Body:
Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Using Tokens¶
Include the access token in the Authorization header:
Refreshing Tokens¶
When the access token expires, use the refresh token to obtain a new one:
Request Body:
Response:
Registration¶
Create a new user account:
Request Body:
{
"email": "user@example.com",
"password": "secure_password",
"first_name": "John",
"last_name": "Doe"
}
Password Reset¶
Request Reset¶
Request Body:
Confirm Reset¶
Request Body:
Error Responses¶
Invalid Credentials¶
Token Invalid/Expired¶
Rate Limiting¶
Security Considerations¶
- Token Storage
- Store tokens securely
- Never store in localStorage
-
Use httpOnly cookies when possible
-
Token Expiration
- Access tokens expire in 60 minutes
- Refresh tokens expire in 24 hours
-
Implement proper token refresh logic
-
HTTPS
- All authentication requests must use HTTPS
-
Non-HTTPS requests will be rejected
-
Rate Limiting
- Login attempts: 5 per minute
- Password reset: 3 per hour
- Token refresh: 10 per minute