Skip to content

Segfaul/fastapi_jwt_sample

Repository files navigation

FASTAPI JWT AUTH SAMPLE

FastAPI based jwt authorization microservice sample.


Project Status

Completed v0.0.1 ✓


Functionality

Users API

/user

- [GET] /api/v1/user: list all users.
- [GET] /api/v1/user/{user_id}: get specific user by id.
- [POST] /api/v1/user: add user.
- [PATCH] /api/v1/user/{user_id}: update existing user by id.
- [DELETE] /api/v1/user/{user_id}: delete existing user by id.

/auth

- [POST] /api/v1/auth/token: login for access & refresh token.
- [POST] /api/v1/auth/refresh: refresh access token with cookie-stored refresh one.
- [POST] /api/v1/auth/logout: remove existing refresh token from db and cookies.

Technologies and Frameworks


Development

  1. Clone the repository to the local machine

    git clone https://github.com/Segfaul/fastapi_jwt_sample.git
    сd fastapi_jwt_sample/
  2. Build images and run app in dev mode

    docker compose -f docker-compose.dev.yml up -d --build
  3. Checkout http://127.0.0.1:8000/api/swagger (Uvicorn, Swagger)

    # Also you may run tests if needed
    docker exec -it users_app_dev-users_api-1 bash
    pytest backend/users/
    exit
  4. Stop/Down the app

    # Without removing containers
    docker compose -f docker-compose.dev.yml stop
    
    # Removing containers
    docker compose -f docker-compose.dev.yml down
    
    # Removing containers and docker volumes (not local ones)
    docker compose -f docker-compose.dev.yml down -v