casbin-fastapi-decorator-file
File-based enforcer provider with hot-reload for casbin-fastapi-decorator.
Provides CachedFileEnforcerProvider — loads the casbin Enforcer once from model.conf + policy.csv and automatically reloads when either file changes on disk (via watchdog).
Install
pip install casbin-fastapi-decorator-file
Usage
from contextlib import asynccontextmanager
from fastapi import FastAPI, HTTPException
from casbin_fastapi_decorator import PermissionGuard
from casbin_fastapi_decorator_file import CachedFileEnforcerProvider
provider = CachedFileEnforcerProvider(
model_path="casbin/model.conf",
policy_path="casbin/policy.csv",
)
@asynccontextmanager
async def lifespan(app: FastAPI):
async with provider: # starts file watcher
yield # stops file watcher on shutdown
guard = PermissionGuard(
user_provider=get_current_user,
enforcer_provider=provider,
error_factory=lambda *_: HTTPException(403, "Forbidden"),
)
app = FastAPI(lifespan=lifespan)
@app.get("/articles")
@guard.require_permission("articles", "read")
async def list_articles(): ...
Any change to model.conf or policy.csv is detected automatically — the enforcer reloads on the next request with zero downtime.
Metadata
Release files for casbin-fastapi-decorator-file 1.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 | Actions |
|---|---|---|---|---|
| casbin_fastapi_decorator_file-1.3.1.tar.gz | 2.9 kB | Without provenance | Details for casbin_fastapi_decorator_file-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| casbin_fastapi_decorator_file-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for casbin_fastapi_decorator_file-1.3.1-py3-none-any.whl |
Total release size: 6.9 kB
Release files / casbin_fastapi_decorator_file-1.3.1.tar.gz
| Download URL | casbin_fastapi_decorator_file-1.3.1.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d1eda8d0a49f0160b098c33ca9338c6e126a69ced018bd93f2d84fcdd510d55
|
|
BLAKE2b-256 checksum How to use checksums |
6972251d4e7a7300701ec0462c5d637d5723065c86f4e0947c26258dd8f5905c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / casbin_fastapi_decorator_file-1.3.1-py3-none-any.whl
| Download URL | casbin_fastapi_decorator_file-1.3.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
226ba761abb546086ba864a5dd51fa809ed67084bd48cadb79c1b262302f3c8c
|
|
BLAKE2b-256 checksum How to use checksums |
d84641542d8eadbd2cd3b28b9d59230448edc7d821c11d6594e699c3a87d7ea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for casbin-fastapi-decorator-file 1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.