This document describes the authentication system implemented for the MbetterClient API endpoints to ensure that logged-in users (admin/cashier) can access the API endpoints securely.
This document provides comprehensive documentation of the authentication system for the MbetterClient API endpoints, ensuring that logged-in users (admin/cashier) can access the API endpoints securely.
## Authentication System
## Authentication System Architecture
The system uses a multi-layered authentication approach:
The MbetterClient application uses a dual authentication system:
### 1. JWT (JSON Web Tokens)
- Short-lived access tokens for web interface authentication
- Generated via `/auth/token` endpoint with username/password
- Used for API requests with `Authorization: Bearer <token>` header
1.**Web-based Authentication**: Uses Flask-Login with user sessions for web interface access
2.**API Authentication**: Uses JWT (JSON Web Tokens) and API tokens for programmatic API access
### 2. API Tokens
- Long-lived tokens for programmatic access
- Created and managed via the web dashboard
- Used for API requests with `Authorization: Bearer <api_token>` header
- Role-based access control is implemented correctly
- Admin-only endpoints are properly protected
- Localhost access is maintained for development
- JWT and API token authentication works for all endpoints
- Comprehensive error handling is in place
The system provides a secure foundation for the MbetterClient application while maintaining flexibility for different user roles and access requirements.
\ No newline at end of file
Check authentication logs for detailed error information.
## API Authentication Summary
The MbetterClient API provides comprehensive authentication and authorization:
-**Role-Based Access Control**: Admin, cashier, and normal user roles
-**API Token Support**: Long-lived tokens for programmatic access
-**Proper Error Handling**: Clear error responses for authentication failures
-**Extensive Coverage**: All sensitive endpoints are properly protected
-**Public Endpoints**: Limited public endpoints for bet verification
This authentication system ensures that logged-in users (admin/cashier) can securely access the API endpoints while maintaining proper access control and security.