User Authentication Service

A FastAPI-based user authentication service with JWT token authentication and SQLite database.

Features

  • User registration and login
  • JWT token-based authentication
  • Password hashing with bcrypt
  • SQLite database with SQLAlchemy ORM
  • Alembic database migrations
  • CORS enabled for all origins
  • Health check endpoint

API Endpoints

  • GET / - Service information and links
  • GET /health - Health check endpoint
  • POST /auth/register - User registration
  • POST /auth/login - User login
  • GET /auth/me - Get current user profile (requires authentication)
  • GET /docs - Interactive API documentation
  • GET /redoc - Alternative API documentation

Setup

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Set environment variables:

    export SECRET_KEY="your-secret-key-here"
    

    Note: The SECRET_KEY environment variable is required for JWT token generation. Make sure to set it to a secure random string in production.

  3. Run database migrations:

    alembic upgrade head
    
  4. Start the application:

    uvicorn main:app --reload
    

The application will be available at http://localhost:8000

Environment Variables

  • SECRET_KEY - Secret key for JWT token signing (required)

Database

The application uses SQLite database stored at /app/storage/db/db.sqlite. The database directory will be created automatically on first run.

Description
Project: User Authentication Service
Readme 36 KiB
Languages
Python 94.5%
Mako 5.5%