Skip to content

caffeinated01/fastapi-auth

Repository files navigation

FastAPI Auth

A simple, from scratch implementation of token-based authentication using FastAPI.

Setup and Installation

Note: Endpoints requiring refresh tokens only work on localhost because Secure cookies demand HTTPS. To enable HTTPS elsewhere, configure Traefik with Docker Compose as a proxy.

Environment Variables

Use the .env template provided and replace the values

Running with Docker

  1. Build and start the container:
    docker-compose up --build
    The application will start at http://localhost:8000. Database migrations will run automatically on startup.

Running Locally

  1. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # or .venv\Scripts\Activate.ps1 on Windows
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run migrations:

    alembic upgrade head
  4. Start FastAPI:

    fastapi dev app/main.py

Usage

Head to the /docs endpoint for FastAPI's autogenerated documentation!

About

A simple, from scratch implementation of token-based authentication using FastAPI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages