A full-stack web authentication system built using FastAPI and React, implementing secure JWT-based authentication with HTTP-only cookies, user registration, login, protected routes, and logout functionality.
- 🔐 Secure login and registration using JWT tokens (stored in HTTP-only cookies)
- 🔒 Password hashing with bcrypt
- ✅ Protected API routes using FastAPI dependencies
- 🧪 Integration tests with Pytest
- 🎯 Token expiration, logout, and cookie invalidation
- 🌐 CORS configuration for frontend/backend communication
- React (Hooks, Axios, React Router)
- JavaScript (ES6+)
- HTML5, CSS3
- FastAPI
- Python
- Pydantic
- bcrypt, JWT
- Pytest (Unit & Integration Tests)
git clone https://github.com/Darrius-W/Auth-Python.git
cd FastAPI-React-Auth
cd server
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload
cd client
npm install
npm start
cd server
pytest
- Signup or Login from React frontend
- Backend returns JWT token in an HTTP-only cookie
- Protected routes are accessed only if token is valid
/logout
deletes cookie and ends session
- Visit
/profile
to see a protected page after logging in - Manually clear cookies or logout to simulate session expiration
- ✅ Tested signup, login, protected route access, and logout with Pytest
- ✅ Simulated cookie handling in test client
- ✅ Covers valid and invalid authentication paths