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)
1.**Web-based Authentication**: Uses Flask-Login with user sessions for web interface access
- Short-lived access tokens for web interface authentication
2.**API Authentication**: Uses JWT (JSON Web Tokens) and API tokens for programmatic API access
- Generated via `/auth/token` endpoint with username/password
- Used for API requests with `Authorization: Bearer <token>` header
-**Role-Based Access Control**: Admin, cashier, and normal user roles
### Request Security
-**API Token Support**: Long-lived tokens for programmatic access
- Always use HTTPS in production
-**Proper Error Handling**: Clear error responses for authentication failures
- Validate all input data
-**Extensive Coverage**: All sensitive endpoints are properly protected
- Implement rate limiting
-**Public Endpoints**: Limited public endpoints for bet verification
- Log authentication attempts
This authentication system ensures that logged-in users (admin/cashier) can securely access the API endpoints while maintaining proper access control and security.
### Role Management
\ No newline at end of file
- Follow principle of least privilege
- Regularly audit user roles
- Remove unnecessary admin access
- Document role requirements
## Implementation Summary
### Changes Made
1.**Added authentication decorators** to all previously unprotected API endpoints
2.**Implemented role-based access control** for sensitive endpoints
3.**Enhanced security** for admin-only endpoints
4.**Maintained localhost access** for development convenience
5.**Documented authentication requirements** for all endpoints
- 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.