Flask-RPBAC
Flask-RPBAC is a lightweight Flask authorization extension for expressing role-based and permission-based access control in a clean, composable way. It is designed for applications that need explicit access checks without turning authorization logic into a large set of ad hoc conditionals.
For the full documentation, including installation, quick start, API reference, and examples, please see the project docs on Read the Docs: https://flask-rpbac.readthedocs.io/en/latest/
The library supports:
role-based access checks
permission-based access checks
combined authorization rules with All, Any, and Not
request- and object-level checks with Predicate
composable requirement objects using & and | operators
blueprint-level protection alongside route-level protection
loader callbacks for roles, permissions, and user data
What it does
Flask-RPBAC lets you define authorization rules in a declarative style and apply them to Flask routes or entire blueprints. This keeps access decisions readable, testable, and easy to evolve as an application grows.
Typical use cases include:
restricting admin-only endpoints
enforcing permission checks for resource actions
combining role and permission requirements for complex policies
protecting blueprint sections with general access rules while keeping route-specific rules
Quick example
from flask import Flask
from flask_login import current_user
from flask_rpbac import RPBAC, Role, Permission, All, Any, Not, Predicate
app = Flask(__name__)
rpbac = RPBAC(app)
@rpbac.role_loader
def load_roles():
return ["admin", "editor"] if current_user.is_authenticated else []
@rpbac.permission_loader
def load_permissions():
return ["post:read", "post:write"] if current_user.is_authenticated else []
@app.route("/admin")
@rpbac.role_required(Role("admin"))
def admin_panel():
return "Admin panel"
@app.route("/publish")
@rpbac.required(All(Role("editor"), Permission("post:write")))
def publish_post():
return "Publish"
@app.route("/shared")
@rpbac.required(Any(Role("admin"), Permission("post:read")))
def shared_view():
return "Shared view"
@app.route("/not-admin")
@rpbac.required(Not(Role("admin")))
def not_admin_view():
return "Non-admin view"
Installation
Install the package with pip:
pip install flask_rpbac
Requirements
Flask-RPBAC targets modern Flask applications and is designed for Flask 3.1 and newer, with Python 3.12+ support.
Contributing
Contributions are welcome. Please read the full contribution guide before opening a pull request.
We encourage pull requests, issue reports, and improvements to documentation, tests, and access control examples. A healthy contribution workflow is:
open an issue or discussion for larger changes
keep changes focused and easy to review
add or update tests for behavior changes
keep the public API clear and consistent
update documentation when user-facing behavior changes
follow the project coding and testing standards already in place
Before submitting changes, please run the project test suite and ensure the relevant checks pass. If you are improving behavior, add a regression test so the change is protected in the future.
Useful contributor resources:
Before submitting a change, contributors should have Python 3.12 or newer, create a virtual environment, install the development dependencies, and verify the project locally:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
tox
Please report security vulnerabilities privately through the process described in the Security Policy, rather than opening a public issue.
License
This project is distributed under the terms of the repository’s license.
Metadata
Release files for Flask-RPBAC 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flask_rpbac-0.3.1.tar.gz | 27.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_rpbac-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.8 kB
Release files / flask_rpbac-0.3.1.tar.gz
| Download URL | flask_rpbac-0.3.1.tar.gz |
|---|---|
| Size | 27.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
554ff287a3eb11840e8e95b48a9d64824a4fb4412096be973787f48b67449992
|
|
BLAKE2b-256 checksum How to use checksums |
8243f11a36b0639ae1044e657846c77f51c99f712ccad49d5c779004723be1cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / flask_rpbac-0.3.1-py3-none-any.whl
| Download URL | flask_rpbac-0.3.1-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb90af6856ed5fb0defef921c0229e495313278dcf6e5154fc0e5095b7a39332
|
|
BLAKE2b-256 checksum How to use checksums |
7657b880cd313aed30dc04f6c277393c0a1c2a8b91122e01bdac666037c22bda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for Flask-RPBAC 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for flask_rpbac-0.3.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.