Skip to main content

File based RBAC in Python made easy.

Project description

Coverage Black Test Publish Gh-Pages License Python version

Documentation

https://rafsaf.github.io/respo/

Installation

pip install respo[all]

Introduction

respo states for resource policy and is tiny, user friendly tool for building RBAC systems based on static yml file, mainly with FastAPI framework in mind. In most cases – for even large set of roles – single file would be enough to provide restricting system access.

Features:

  • It provides custom fields for SQLAlchemy and Django to store users roles in database.

  • Implements R. Sandhu Role-based access control text.

  • Dead simple, fast and can be trusted – 100% coverage.

  • No issues with mutlithreading and multiprocessing – you just pass around already prepared, compiled respo_model (from file) in your app that is readonly.

  • Generates your roles, permissions offline and compile it to pickle file for superfast access in an app.

  • Detailed documentation and error messages in CLI command.

  • 100% autocompletion and typing support with optional code generation for even better typing support.


Note, every piece of code in the docs is a tested python/yml file, feel free to use it.

Usage in FastAPI

The goal is to use simple and reusable dependency factory user_have_permission("some permission") that will verify just having User database instance if user have access to resoruce. Single endpoint must have single permission for it, and thanks to respo compilation step, every "stronger" permissions and roles would include "weaker" so we don't need to have the if statements everywhere around application.

from .dependencies import user_have_permission

...


@router.get("/users/read_all/")
def users_read_all(user = Depends(user_have_permission("users.read_all"))):
    return user

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respo-1.0.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

respo-1.0.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file respo-1.0.0.tar.gz.

File metadata

  • Download URL: respo-1.0.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for respo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8c8c1c3dc60491e5d080f506599846197221d7b5c2f648a64af3bc3c4331b393
MD5 8b1a587abb9039d8c04eed906a9b6085
BLAKE2b-256 e75b2da180efb804961e19bd537e7659087b62f4d8033d555cfa44405202e106

See more details on using hashes here.

File details

Details for the file respo-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: respo-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for respo-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f985062732c03bca7333319307fbf235104201a600b32534a8b98cd056bf1707
MD5 300f6853f7b0b2e83172f637c27b81a0
BLAKE2b-256 fffeda083f700a815c73950ba536869b4d98b93cd67cb3bb1665fda060dd2d6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page