https://github.com/steqa/fastapi-jwt-template
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.
https://github.com/steqa/fastapi-jwt-template
alembic fastapi postgresql python redis template
Last synced: 12 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/steqa/fastapi-jwt-template
- Owner: steqa
- License: mit
- Created: 2025-02-17T14:07:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-18T07:33:19.000Z (over 1 year ago)
- Last Synced: 2025-02-18T08:32:17.049Z (over 1 year ago)
- Topics: alembic, fastapi, postgresql, python, redis, template
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[en](README.md) [ru](locale/README.ru.md)
# Fast JWTemplate :rocket:
 
    
## Content
1. [Description](#description)
2. [Features](#features)
3. [Prerequisites](#prerequisites)
4. [Setup](#setup)
5. [Usage](#usage)
6. [License](#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](https://www.docker.com/get-started).
## Setup
1. **Clone the repository**
```bash
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**
```bash
cd project-folder
```
```bash
docker compose -f docker/docker-compose.yml --env-file .env up --build
```
## Usage
- The API will be available at http://localhost:8000
- You can interact with the API using Swagger UI at http://localhost:8000/docs
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.