Table of Contents
Implementing a user model in your application always seems like a painful task, at least to me. It's always the exact same code with minor configurations but it still takes a lot of time to build and add to the codebase. That's why, I decided to put all the core user model code in one place so that all it takes to integrate one in your existing application, is just a few quick changes.
This template implements a complete, secure, fast, and easy-to-add user sign in and sign up model code that works on the OAuth2 password-based-auth-flow and preserves and authorises the user on the basis of JWT tokens, for FastAPI-based applications.
All you need to do is to modify the database schemas according to your needs (or leave it the same depending upon what you want), and add your database handling code to the file, that connects and handles the queries from whatever database engine your application is using.
- Clone the repo.
git clone https://github.com/outoflaksh/fastapi-jwt-auth-template.git
- Change your working directory to the cloned repo.
cd fastapi-jwt-auth-template
- Install the dependencies.
python3 -m pip install -r ./requirements.txt OR pip install -r ./requirements.txt
- Start the FastAPI server with Uvicorn.
uvicorn main:app