FastAPI 权限检查库 (参考 mwpermission Flask 版本重构)
Project description
FastAPI 权限检查库,参考 mwpermission (Flask 版本) 重构为 FastAPI 版本。
功能特点
支持 FastAPI 依赖注入系统的权限检查
支持装饰器风格的权限验证
开发模式下可跳过权限检查
支持动态权限检查
安装方法
pip install mwpermission-fastapi
快速开始
创建 FastAPI 应用并配置权限
from fastapi import FastAPI, Depends
from mwpermission_fastapi import Permission
app = FastAPI()
# 初始化权限检查器
p = Permission(sysname="maxwinweb")
使用说明
初始化权限检查器后,可以使用以下方式保护您的API端点:
# 检查用户对 employee 模块的查看权限
@app.get("/employees")
async def get_employees(user_id: int = Depends(p.check("employee", ["view"]))):
return {"message": "employees list"}
更多详细信息,请参见完整文档。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mwpermission_fastapi-0.1.0.tar.gz.
File metadata
- Download URL: mwpermission_fastapi-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe4d0c1cd563da86776198d877f64d6c47e204a7bee8808fbc406f496f94f648
|
|
| MD5 |
d0542d0161ce35148c39faa227f523ed
|
|
| BLAKE2b-256 |
c76979046ace24b844f8b367bc1a8f8a158491e6c7cf95f13011c79fa6e9285c
|
File details
Details for the file mwpermission_fastapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mwpermission_fastapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20954719fbb3a3d2ddcb58c0034318813c6aca68e3278fc135aa45cfec227349
|
|
| MD5 |
7a8a66e646e4138f037fbde5a5f21336
|
|
| BLAKE2b-256 |
340f6d26b4cc1ba5bb5ef303ee79379fd05485cfadf1729a067f1a889d7d717e
|