Automated Action 794d172f85 Add user authentication system with login, signup, and JWT tokens
- Added user model and schema definitions
- Implemented JWT token authentication
- Created endpoints for user registration and login
- Added secure password hashing with bcrypt
- Set up SQLite database with SQLAlchemy
- Created Alembic migrations
- Added user management endpoints
- Included health check endpoint

generated with BackendIM... (backend.im)
2025-05-11 22:51:17 +00:00

User Authentication Service

A FastAPI-based authentication service that provides user management, JWT authentication, and secure password handling.

Features

  • User registration (signup) and login
  • JWT token-based authentication
  • Secure password hashing using bcrypt
  • User profile management (view, update, delete)
  • SQLite database with SQLAlchemy ORM
  • Alembic migrations for database version control
  • Health check endpoint

Project Structure

├── alembic/                 # Database migration files
├── app/                     # Application code
│   ├── api/                 # API endpoints
│   │   └── v1/              # API version 1
│   │       └── endpoints/   # API route handlers
│   ├── core/                # Core application code
│   ├── db/                  # Database configuration and repositories
│   ├── middlewares/         # Middleware components
│   ├── models/              # SQLAlchemy ORM models
│   ├── schemas/             # Pydantic schema models
│   └── services/            # Business logic services
├── storage/                 # Storage for SQLite database
└── main.py                  # FastAPI application entry point

API Endpoints

  • Authentication

    • POST /api/v1/auth/register - Register a new user
    • POST /api/v1/auth/login - Login and get access token
    • GET /api/v1/auth/me - Get current user information
  • Users

    • GET /api/v1/users/ - List all users (requires authentication)
    • GET /api/v1/users/{user_id} - Get a specific user (requires authentication)
    • PUT /api/v1/users/{user_id} - Update a user (requires authentication)
    • DELETE /api/v1/users/{user_id} - Delete a user (requires authentication)
  • Health Check

    • GET /health - Check service health status

Getting Started

Prerequisites

  • Python 3.8+
  • pip

Installation

  1. Clone the repository
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Run database migrations:
    alembic upgrade head
    
  4. Start the server:
    uvicorn main:app --reload
    

Documentation

  • Interactive API documentation is available at /docs when the server is running
  • ReDoc documentation is available at /redoc

Security

  • Passwords are hashed using bcrypt
  • Authentication is handled via JWT tokens
  • CORS is enabled and configurable
  • Environment variables can be used to configure secrets

License

MIT

Description
Project: User Authentication Service
Readme 40 KiB
Languages
Python 97.5%
Mako 2.5%