This project is a FastAPI-based user authentication system that provides user registration, login, and password reset functionality. It uses SQLite as the database, bcrypt for password hashing, and Jinja2 templates for rendering HTML pages.
- User Registration: Allows users to create an account with a username, email, and password.
- User Login: Validates user credentials and authenticates users.
- Password Reset: Generates a reset token and allows users to set a new password.
- HTML Templates: Provides user-friendly interfaces for authentication pages.
- FastAPI: A modern web framework for building APIs with Python.
- SQLite: Lightweight database for storing user credentials.
- SQLAlchemy: ORM for database interactions.
- Jinja2: Templating engine for rendering HTML.
- Passlib (bcrypt): For secure password hashing.
- Clone the repository:
git clone https://github.com/yourusername/auth-system.git cd auth-system - Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run the FastAPI server:
uvicorn main:app --reload
- Access the application:
- API Docs: http://127.0.0.1:8000/docs
- Web Interface: http://127.0.0.1:8000/register
| Method | Endpoint | Description |
|---|---|---|
| GET | /register |
Show registration form |
| POST | /register |
Register a new user |
| GET | /login |
Show login form |
| POST | /login |
Authenticate user |
| GET | /reset_password |
Show password reset form |
| POST | /reset_password |
Generate a password reset token |
| GET | /set_new_password/{token} |
Show new password form |
| POST | /set_new_password/{token} |
Set a new password for user |
This project is licensed under the MIT License.