Automated Action 9c818fbd91 Implement complete user authentication system with FastAPI
- Set up FastAPI application with CORS and proper structure
- Created User model with SQLAlchemy and SQLite database
- Implemented JWT-based authentication with bcrypt password hashing
- Added user registration, login, and profile endpoints
- Created health check endpoint for monitoring
- Set up Alembic for database migrations
- Added comprehensive API documentation
- Configured proper project structure with separate modules
- Updated README with complete setup and usage instructions
2025-06-25 01:56:41 +00:00

65 lines
1.5 KiB
Markdown

# User Authentication Service
A FastAPI-based user authentication service with JWT token support.
## Features
- User registration and login
- JWT token-based authentication
- Password hashing with bcrypt
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- Health check endpoint
- CORS enabled for all origins
- API documentation available at `/docs` and `/redoc`
## Environment Variables
The following environment variables should be set:
- `SECRET_KEY`: JWT secret key for token signing (defaults to "your-secret-key-change-in-production")
## Installation
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Run database migrations:
```bash
alembic upgrade head
```
3. Start the application:
```bash
uvicorn main:app --reload
```
## API Endpoints
### Base
- `GET /` - Service information
- `GET /health` - Health check
### Authentication
- `POST /auth/register` - Register a new user
- `POST /auth/login` - Login user
- `POST /auth/token` - OAuth2 compatible token endpoint
- `GET /auth/me` - Get current user info (requires authentication)
- `POST /auth/logout` - Logout user
## Database Structure
The application uses SQLite with the following user table structure:
- `id`: Primary key
- `email`: Unique user email
- `hashed_password`: Bcrypt hashed password
- `is_active`: User status flag
- `created_at`: Account creation timestamp
- `updated_at`: Last update timestamp
## Development
The project uses Ruff for code formatting and linting.