This project demonstrates a secure client-server architecture with robust cryptographic features, built using FastAPI (Backend) and React (Frontend).
This application implements several core security best practices and cryptographic mechanisms:
- Bcrypt Password Hashing: User passwords are never stored in plain text. We use the Bcrypt hashing algorithm (via
passlib) to securely hash passwords before storage. This protects against rainbow table attacks and brute-force attempts. - JWT Authentication: Stateless authentication is handled using JSON Web Tokens (JWT). Upon login, a signed token is issued containing the user's identity and role. This token is verified on every protected API request, ensuring secure access without server-side sessions.
- Role-Based Access Control (RBAC): The system distinguishes between different user roles (e.g.,
user,admin). API endpoints are protected to ensure that only authorized roles can perform sensitive actions. - OTP Verification: High-security actions like Registration and Password Reset require email-based One-Time Password (OTP) verification, proving ownership of the registered email address.
- Input Validation: All incoming data is rigorously validated using Pydantic schemas. This prevents injection attacks and ensures data integrity by enforcing strict type and format checks (e.g., valid email formats).
- CORS Configuration: Cross-Origin Resource Sharing (CORS) is explicitly configured to allow requests only from trusted frontend origins, preventing unauthorized cross-site requests.
- Python 3.9+
- Node.js 16+
Navigate to the server directory and install the dependencies:
cd server
pip install -r requirements.txtRun the FastAPI server:
uvicorn src.main:app --reloadThe server will start at http://127.0.0.1:8000.
- API Docs:
http://127.0.0.1:8000/docs
Open a new terminal, navigate to the client directory, and install dependencies:
cd client
npm installStart the React development server:
npm startThe application will open at http://localhost:3000.
To run the backend test suite:
cd server
pytest