Code Monkey home page Code Monkey logo

permissions_system's Introduction

Permissions Systems

It's plugin for fastapi (but can be used with similar frameworks) any frameworks, that provides a minimal
setup for maintaining resources and related permissions for user-groups.

How to use it?

application.py

from fastapi import FastAPI
import databases
import sqlalchemy
import os
from permissions_system.PermissionsSystemDatabases import PermissionsS

app = FastAPI()

DB_URI = os.environ["DB_URI"]

database = databases.Database(DB_URI)
metadata = sqlalchemy.MetaData()
ps = PermissionsS(metadata, database, DB_URI)


app.add_event_handler("startup", startup)
app.add_event_handler("shutdown", shutdown)

async def startup():
    await database.connect()
    ps.setup()

for Flask app you will call ps.setup() after db.init(app), assuming you are using flask_sqlalchemy

Step1 - instantiate PermissionsS class.

Step2 - during startup event after database is connected make a call to setup() ************_************

_PermissionsS will then detect your tables add them to resources, add super-admin user-group, if there isn't already one. Everytime there is a new resource that gets added automatically to resources table. User-group super-admin by default has all CRUD permissions for all resources. To add a new user-group and related permissions use built-in functions add_user_group and add_permissions. To get whether a particular user has CRUD permissions for a particular resource you will call > ps.user_has_permissions(user_id:UUID,resource:str,permission_type:PermissionTypesEnum) -> bool*

PermissionsSystem is not like django-admin or flask-admin. It doesn't provide a front-end admin dashboard, but a minimal setup to manage resources and permissions. It aims to provide autonomy and more control over to the developer. For front-end you will end up using something more custom or React-admin or vue-element-admin

Find an example here, to learn how it can be used.

PermissionsSystem now only uses sqlalchemy and is completely sync.

permissions_system's People

Contributors

dependabot[bot] avatar zero-shubham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

permissions_system's Issues

Suggest to loosen the dependency on databases

Hi, your project permissions_system(commit id: d9e882d) requires "databases==0.3.2" in its dependency. After analyzing the source code, we found that the following versions of databases can also be suitable, i.e., databases 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.3.0, 0.3.1, since all functions that you directly (1 APIs: databases.core.Database.init) or indirectly (propagate to 3 databases's internal APIs and 3 outsider APIs) used from the package have not been changed in these versions, thus not affecting your usage.

Therefore, we believe that it is quite safe to loose your dependency on databases from "databases==0.3.2" to "databases>=0.2.2,<=0.3.2". This will improve the applicability of permissions_system and reduce the possibility of any further dependency conflict with other projects.

May I pull a request to further loosen the dependency on databases?

By the way, could you please tell us whether such an automatic tool for dependency analysis may be potentially helpful for maintaining dependencies easier during your development?

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.