FastAPI based jwt authorization microservice sample.
Completed v0.0.1 ✓
/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.
- Python 3.11.6
- FastAPI 0.108
- Uvicorn 0.25.0
- SQLAlchemy 2.0.31
- Alembic 1.13.1
- Pydantic 2.7.4
- PostgreSQL 16
- Docker 26.1.3
- Docker Compose 2.27.0
- Pytest 8.1.1
- CI
-
Clone the repository to the local machine
git clone https://github.com/Segfaul/fastapi_jwt_sample.git сd fastapi_jwt_sample/
-
Build images and run app in dev mode
docker compose -f docker-compose.dev.yml up -d --build
-
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
-
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