Skip to content

steqa/fastapi-jwt-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

en ru

Fast JWTemplate 🚀

GitHub Release License

Python FastAPI PostgreSQL Redis Alembic

Content

  1. Description
  2. Features
  3. Prerequisites
  4. Setup
  5. Usage
  6. License

Description

This is a template for a FastAPI application with JWT authentication. It uses PostgreSQL for the database and Redis for blacklisting refresh tokens. The project is containerized using Docker.

Features

  • Secure JWT-based user authentication with bcrypt hashing for passwords
  • API endpoints for login, logout, and token refresh, with expiration handling
  • Blacklisting refresh tokens in Redis for enhanced security
  • Creating a user with password validation

Endpoints

  1. Login User
    • POST /api/v1/auth/jwt/login
    • Description: Authenticates a user and returns an access token and refresh token.
  2. Refresh Token
    • POST /api/v1/auth/jwt/refresh
    • Description: Refreshes the user's JWT access token using the provided refresh token.
  3. Logout User
    • POST /api/v1/auth/jwt/logout
    • Description: Logs out the user by blocking the refresh token.
  4. Create User
    • POST /api/v1/users
    • Description: Creates a new user in the system.
  5. Get Current User
    • GET /api/v1/users/me
    • Description: Retrieves the details of the currently authenticated user.

Prerequisites

Make sure Docker is installed and running on your system. You can download it from here.

Setup

  1. Clone the repository

    git clone https://github.com/steqa/fast-jwtemplate.git project-folder
  2. Update the .env file

    Rename .env.example to .env and update with your configuration

  3. Build and start the Docker containers

    cd project-folder
    docker compose -f docker/docker-compose.yml --env-file .env up --build

Usage

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

This is a template for a FastAPI application with JWT authentication. It uses PostgreSQL for the database and Redis for blacklisting refresh tokens. The project is containerized using Docker.

Topics

Resources

License

Stars

Watchers

Forks

Contributors