Skip to main content
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

Release files for respo 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for respo 1.0.0
File Size Uploaded
respo-1.0.0.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for respo 1.0.0
File Interpreter ABI Platform
respo-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.5 kB

Release files / respo-1.0.0.tar.gz

Download URL respo-1.0.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8c8c1c3dc60491e5d080f506599846197221d7b5c2f648a64af3bc3c4331b393
BLAKE2b-256 checksum
How to use checksums
e75b2da180efb804961e19bd537e7659087b62f4d8033d555cfa44405202e106
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release files / respo-1.0.0-py3-none-any.whl

Download URL respo-1.0.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f985062732c03bca7333319307fbf235104201a600b32534a8b98cd056bf1707
BLAKE2b-256 checksum
How to use checksums
fffeda083f700a815c73950ba536869b4d98b93cd67cb3bb1665fda060dd2d6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page