Skip to main content

Configurable FastAPI middleware for input/output sanitization

Project description

fastapi-sanitizer-example

A configurable FastAPI middleware that sanitizes JSON request/response fields using bleach.

Quick usage

from fastapi import FastAPI
from fastapi_sanitizer import SanitizerMiddleware

app = FastAPI()

app.add_middleware(
    SanitizerMiddleware,
    allowed_tags=["b", "i", "u"],
    script_allowed_fields=["code_snippet"],
    whitelist_fields=["system_status"],
)

@app.post("/demo")
def demo(data: dict):
    return {"received": data}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_sanitize-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_sanitize-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_sanitize-0.0.1.tar.gz.

File metadata

  • Download URL: fastapi_sanitize-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for fastapi_sanitize-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7fa846b5768c24003e61091d94a7ab78c2515ce6020fda70f6c0448c583cd6ab
MD5 c4511cbd51ce17b7d43533f141b3e5b0
BLAKE2b-256 c3fdba7b4a7f3900ca2a0945af5a662af0d33b3a5c26c85cd3426fe63f50e3bd

See more details on using hashes here.

File details

Details for the file fastapi_sanitize-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_sanitize-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5b66cbb115ba99c7656211f065474bf3f12184cae575c435291e4a1a11732c2
MD5 3678a25d1059abb18d7d8e57ae42ca41
BLAKE2b-256 2d58ded25811db0da6397e4625f182f1878139d98cc5c4568f84f4ddb9665d70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page