Skip to main content

mwpermission-fastapi

FastAPI 权限检查库,参考 mwpermission (Flask 版本) 重构为 FastAPI 版本。

功能特点

  • 支持 FastAPI 依赖注入系统的权限检查

  • 支持装饰器风格的权限验证

  • 开发模式下可跳过权限检查

  • 支持动态权限检查

安装方法

pip install mwpermission-fastapi

快速开始

  1. 创建 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"}

更多详细信息,请参见完整文档。

Metadata

Release files for mwpermission-fastapi 0.1.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 mwpermission-fastapi 0.1.0
File Size Uploaded Provenance
mwpermission_fastapi-0.1.0.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mwpermission-fastapi 0.1.0
File Interpreter ABI Platform
mwpermission_fastapi-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / mwpermission_fastapi-0.1.0.tar.gz

Download URL mwpermission_fastapi-0.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fe4d0c1cd563da86776198d877f64d6c47e204a7bee8808fbc406f496f94f648
BLAKE2b-256 checksum
How to use checksums
c76979046ace24b844f8b367bc1a8f8a158491e6c7cf95f13011c79fa6e9285c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / mwpermission_fastapi-0.1.0-py3-none-any.whl

Download URL mwpermission_fastapi-0.1.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20954719fbb3a3d2ddcb58c0034318813c6aca68e3278fc135aa45cfec227349
BLAKE2b-256 checksum
How to use checksums
340f6d26b4cc1ba5bb5ef303ee79379fd05485cfadf1729a067f1a889d7d717e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for mwpermission-fastapi 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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