Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⭐

Overview

Header

FRDP CodeFactor

Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin .

Getting Started

Features

Auth Description
Login Access Token OAuth2 compatible token login, get an access token for future requests
Check Session Test if a user is logged in by checking if a valid access token is in the header
Recover Password Password Recovery
Reset Password Reset your password
User Description
Create New User Create a new user
Get Current User By Id Get current user
Update Current User Update own user
Update Other User (SuperUser) Update a user
Create User (Without Authentication) Create new user without the need to be logged in.

Prerequisites

Project setup

# clone the repo
$ git clone https://github.com/BnademOverflow/FRDP

# move to the project folder
$ cd FRDP

Creating virtual environment

  • Install pipenv a global python project pip install pipenv
  • Create a virtual environment for this project
# creating pipenv environment for python 3
$ pipenv --three

# activating the pipenv environment
$ pipenv shell

# if you have multiple python 3 versions installed then
$ pipenv install -d --python 3.8

# install all dependencies (include -d for installing dev dependencies)
$ pipenv install -d

Configured Enviromment

Database

  • Using SQLAlchemy to Connect to our PostgreSQL Database
  • Containerization The Database.
  • Drop your PostgreSQL Configuration at the .env.sample and Don't Forget to change the Name to .env
# example of Configuration for the .env file

# Generate secret key using openssl rand -hex 32
SECRET_KEY= 4yi87D8FHRucoVyKXFUcMC/yb5YpLxz6PRX6YHm4kLU

# Email Defaut Intiger ex. 30, 60, 90
EMAIL_RESET_TOKEN_EXPIRE_HOURS= 60

# Server Default
SERVER_NAME=API
SERVER_HOST=http://localhost:8900

# Postgres default username and password
POSTGRES_USER=admin
POSTGRES_PASSWORD=admin
POSTGRES_DB=admin
POSTGRES_PORT=5500
POSTGRES_SERVER=localhost

PGADMIN_LISTEN_PORT=5050
PGADM[email protected]
PGADMIN_DEFAULT_PASSWORD=admin

Running the Application

  • To run the Main we need to use uvicorn a lightning-fast ASGI server implementation, using uvloop and httptools.
# To run the Application under a reload enviromment use -- reload
$ uvicorn main:app --reload

Running the Docker Container

  • We have the Dockerfile created in above section. Now, we will use the Dockerfile to create the image of the FastAPI app and then start the FastAPI app container.
docker build
  • list all the docker images and you can also see the image frdp:latest in the list.
docker images
  • run the application at port 5000. The various options used are:
  • -p: publish the container's port to the host port.
  • -d: run the container in the background.
  • -i: run the container in interactive mode.
  • -t: to allocate pseudo-TTY.
  • --name: name of the container
docker container run -p 5000:5000 -dit --name FRDP frdp:latest
  • Check the status of the docker container
docker container ps

Preconfigured Packages

Includes preconfigured packages to kick start FRDP by just setting appropriate configuration.

Package Usage
uvicorn a lightning-fast ASGI server implementation, using uvloop and httptools.
Python-Jose a JavaScript Object Signing and Encryption implementation in Python.
SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.
starlette a lightweight ASGI framework/toolkit, which is ideal for building high performance asyncio services.
passlib a password hashing library for Python 2 & 3, which provides cross-platform implementations of over 30 password hashing algorithms
bcrypt Good password hashing for your software and your servers.
python-jose The JavaScript Object Signing and Encryption (JOSE) technologies - JSON Web Signature (JWS), JSON Web Encryption (JWE), JSON Web Key (JWK), and JSON Web Algorithms (JWA).
jinja2 a very fast and easy to use stand-alone template engine for Python.
psycopg2 a Python PostgreSQL database adapter.

Contributing

  • Join the FRDP Creator and Contribute to the Project if you have any enhancement or add-ons to create a good and Secure Project, Help any User to Use it in a good and simple way.
  • See the open issues for a list of proposed features (and known issues) or open pull request before starting work on a new feature.
  • Check also Docs for more information about FRDP.
  • Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
  1. Fork the Project
  2. Create your Feature Branch (git checkout -b hello/world)
  3. Commit your Changes (git commit -m 'Add hello world')
  4. Push to the Branch (git push origin feature/helloworld)
  5. Open a Pull Request

License

This project is licensed under the terms of the Apache-2.0 License.

Owner
BnademOverflow
Everything that can be represented as a bit sequence 🚀
BnademOverflow
A minimal FastAPI implementation for Django !

Caution!!! This project is in early developing stage. So use it at you own risk. Bug reports / Fix PRs are welcomed. Installation pip install django-m

toki 23 Dec 24, 2022
Flask-vs-FastAPI - Understanding Flask vs FastAPI Web Framework. A comparison of two different RestAPI frameworks.

Flask-vs-FastAPI Understanding Flask vs FastAPI Web Framework. A comparison of two different RestAPI frameworks. IntroductionIn Flask is a popular mic

Mithlesh Navlakhe 1 Jan 01, 2022
FastAPI native extension, easy and simple JWT auth

fastapi-jwt FastAPI native extension, easy and simple JWT auth

Konstantin Chernyshev 19 Dec 12, 2022
Hook Slinger acts as a simple service that lets you send, retry, and manage event-triggered POST requests, aka webhooks

Hook Slinger acts as a simple service that lets you send, retry, and manage event-triggered POST requests, aka webhooks. It provides a fully self-contained docker image that is easy to orchestrate, m

Redowan Delowar 96 Jan 02, 2023
Run your jupyter notebooks as a REST API endpoint. This isn't a jupyter server but rather just a way to run your notebooks as a REST API Endpoint.

Jupter Notebook REST API Run your jupyter notebooks as a REST API endpoint. This isn't a jupyter server but rather just a way to run your notebooks as

Invictify 54 Nov 04, 2022
Dead simple CSRF security middleware for Starlette ⭐ and Fast API ⚡

csrf-starlette-fastapi Dead simple CSRF security middleware for Starlette ⭐ and Fast API ⚡ Will work with either a input type="hidden" field or ajax

Nathaniel Sabanski 9 Nov 20, 2022
A minimal Streamlit app showing how to launch and stop a FastAPI process on demand

Simple Streamlit + FastAPI Integration A minimal Streamlit app showing how to launch and stop a FastAPI process on demand. The FastAPI /run route simu

Arvindra 18 Jan 02, 2023
Generate Class & Decorators for your FastAPI project ✨🚀

Classes and Decorators to use FastAPI with class based routing. In particular this allows you to construct an instance of a class and have methods of that instance be route handlers for FastAPI & Pyt

Yasser Tahiri 34 Oct 27, 2022
Pagination support for flask

flask-paginate Pagination support for flask framework (study from will_paginate). It supports several css frameworks. It requires Python2.6+ as string

Lix Xu 264 Nov 07, 2022
fastapi-cache is a tool to cache fastapi response and function result, with backends support redis and memcached.

fastapi-cache Introduction fastapi-cache is a tool to cache fastapi response and function result, with backends support redis, memcache, and dynamodb.

long2ice 551 Jan 08, 2023
Ready-to-use and customizable users management for FastAPI

FastAPI Users Ready-to-use and customizable users management for FastAPI Documentation: https://fastapi-users.github.io/fastapi-users/ Source Code: ht

FastAPI Users 2.3k Dec 30, 2022
Simple FastAPI Example : Blog API using FastAPI : Beginner Friendly

fastapi_blog FastAPI : Simple Blog API with CRUD operation Steps to run the project: git clone https://github.com/mrAvi07/fastapi_blog.git cd fastapi-

Avinash Alanjkar 1 Oct 08, 2022
Easily integrate socket.io with your FastAPI app 🚀

fastapi-socketio Easly integrate socket.io with your FastAPI app. Installation Install this plugin using pip: $ pip install fastapi-socketio Usage To

Srdjan Stankovic 210 Dec 23, 2022
LuSyringe is a documentation injection tool for your classes when using Fast API

LuSyringe LuSyringe is a documentation injection tool for your classes when using Fast API Benefits The main benefit is being able to separate your bu

Enzo Ferrari 2 Sep 06, 2021
Reusable utilities for FastAPI

Reusable utilities for FastAPI Documentation: https://fastapi-utils.davidmontague.xyz Source Code: https://github.com/dmontagu/fastapi-utils FastAPI i

David Montague 1.3k Jan 04, 2023
✨️🐍 SPARQL endpoint built with RDFLib to serve machine learning models, or any other logic implemented in Python

✨ SPARQL endpoint for RDFLib rdflib-endpoint is a SPARQL endpoint based on a RDFLib Graph to easily serve machine learning models, or any other logic

Vincent Emonet 27 Dec 19, 2022
implementation of deta base for FastAPIUsers

FastAPI Users - Database adapter for Deta Base Ready-to-use and customizable users management for FastAPI Documentation: https://fastapi-users.github.

2 Aug 15, 2022
Learn to deploy a FastAPI application into production DigitalOcean App Platform

Learn to deploy a FastAPI application into production DigitalOcean App Platform. This is a microservice for our Try Django 3.2 project. The goal is to extract any and all text from images using a tec

Coding For Entrepreneurs 59 Nov 29, 2022
Fastapi-ml-template - Fastapi ml template with python

FastAPI ML Template Run Web API Local $ sh run.sh # poetry run uvicorn app.mai

Yuki Okuda 29 Nov 20, 2022
FastAPI Socket.io with first-class documentation using AsyncAPI

fastapi-sio Socket.io FastAPI integration library with first-class documentation using AsyncAPI The usage of the library is very familiar to the exper

Marián Hlaváč 9 Jan 02, 2023