GithubHelp home page GithubHelp logo

mahmudjewel / fastapi-role-based-auth Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 58 KB

Python 96.70% Mako 3.30%
fastapi-rbac access-control-in-fastapi fastapi-authorization-decorators fastapi-role-based-security fastapi-security-roles permissions-in-fastapi rbac-in-fastapi rbac-middleware-fastapi role-based-authorization-fastapi user-roles-fastapi fastapi-access-levels fastapi-custom-authorization fastapi-group-based-authorization fastapi-jwt-rbac fastapi-rbac-best-practices fastapi-user-management fastapi-user-permissions secure-api-with-fastapi-rbac

fastapi-role-based-auth's Introduction

FastAPI-Role Based Access Control

There are multiple types of user like

  • customer
  • admin
  • vendor
    • They have different access control on the project.

Covered topics

  • Enum types
  • Abstract model like common model
  • RBAC with dependenies and routes.
  • Datetime in SQLAlchemy and Pydantic
  • Alembic = database migrations
  • Alembic = database migrations
  • sqladmin = SQLAlchemy Admin

Developed API

SRL METHOD ROUTE FUNCTIONALITY Required Fields ACCESS
1 POST /auth/token Login user email, password All users
2 POST /auth/users/ Create new user email, password Anyone
3 GET /auth/users/ Get all users list None admin
4 GET /auth/users/me/ Get current user details None authorized
5 GET /auth/users/{user_id} Get indivisual users details None Admin
6 PATCH /auth/users/{user_id} Update the user partially email, password, is_active, role Admin
7 DELETE auth/users/{user_id} Delete the user None admin
8 GET / Home page None anyone
9 GET /admin Admin Dashboard None admin_

Tools

Back-end

Language:

Python (3.11.6)

Frameworks:

FastAPI (0.108.0)
pydantic (2.5.3)

Other libraries / tools:

SQLAlchemy == 2.0.25
starlette == 0.32.0.post1
uvicorn == 0.25.0
python-jose == 3.3.0
alembic == 1.13.1

Database:

SQLite

Setup

The first thing to do is to clone the repository:

$ https://github.com/MahmudJewel/FastAPI-Role-based-auth

Create a virtual environment to install dependencies in and activate it:

$ cd FastAPI-jwt-auth
$ python -m venv venv
$ source venv/bin/activate

Then install the dependencies:

(venv)$ pip install -r requirements.txt

Note the (venv) in front of the prompt. This indicates that this terminal session operates in a virtual environment set up by virtualenv2.

Once pip has finished downloading the dependencies:

(venv)$ uvicorn core.main:app --reload

Happy Coding

From ==> Juwel Mahmud

fastapi-role-based-auth's People

Contributors

mahmudjewel avatar

Stargazers

 avatar  avatar Noyan Tendikov avatar

Watchers

 avatar

Forkers

evinai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.