Skip to main content

🧙 asgi-sage

Test Suite Package version

Security Headers Middleware for Asgi App heavily inspired by flask-talisman

Installation

pip install asgi-sage

Usage

from asgi_sage.middleware import SageMiddleware

async def app(scope, receive, send):
    assert scope["type"] == "http"
    headers = [(b"content-type", "text/plain")]
    await send({"type": "http.response.start", "status": 200, "headers": headers})
    await send({"type": "http.response.body", "body": b"Hello, world!"})

app = SageMiddleware(app)

Options

  • feature_policy: dict = {}, force_https: bool = True
  • force_https: bool = False
  • force_https_permanent: bool = False
  • frame_options: Optional[str] = "SAMEORIGIN"
  • strict_transport_security: bool = True
  • strict_transport_security_preload: bool = False
  • strict_transport_security_max_age: int = 60 * 60 * 24 * 365
  • strict_transport_security_include_subdomains: bool = True
  • content_security_policy: Optional[dict] = None
  • referrer_policy: str = "strict-origin-when-cross-origin"
  • session_cookie_secure: bool = True
  • session_cookie_http_only: bool = True
  • content_type_nosniff: bool = True

Road Map

  • Per Request overriding

  • Add tests for different ASGI frameworks like Quart and Django 3.0+

  • Properly support websockets

  • Auto Changelog

License

MIT

Metadata

Release files for asgi-sage 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asgi-sage 0.1.2
File Size Uploaded
asgi-sage-0.1.2.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asgi-sage 0.1.2
File Interpreter ABI Platform
asgi_sage-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / asgi-sage-0.1.2.tar.gz

Download URL asgi-sage-0.1.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b11590c4500ce4a8bf5ca47ea4a0a215773f974d159f41e917c6fdba2488f35b
BLAKE2b-256 checksum
How to use checksums
44609462af2c6b59c27c0c7c1e706e4142de64930a60b0a62c537d486d0042ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.6.10 Linux/5.3.0-7648-generic

Release files / asgi_sage-0.1.2-py3-none-any.whl

Download URL asgi_sage-0.1.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63f76e8e61dd17680e7bb03457d33a6160aa87f09785f1c04fa34d9b06c121d0
BLAKE2b-256 checksum
How to use checksums
12ec816b852488deace74e78351d9d81aeac7dfafd26751d7e30190392fd90c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.6.10 Linux/5.3.0-7648-generic

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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