Skip to main content

Security Headers for asgi apps

Project description

asgi-sage

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

Road Map

  • Per Request overriding
  • Add tests for different ASGI frameworks like Quart and Django 3.0+
  • Properly support websockets

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

asgi-sage-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

asgi_sage-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file asgi-sage-0.1.0.tar.gz.

File metadata

  • Download URL: asgi-sage-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.10 Linux/5.3.0-7648-generic

File hashes

Hashes for asgi-sage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 599ba77bdfcfdf83498062c3433551b630e9fee4fb5ba7dbaf2d427db98438fe
MD5 ebbc823a312cdf24e3d8b6c4692808d2
BLAKE2b-256 48776f50e8c1ef9a51686ff712d29c3f7d2e6dcb8f75c86c8357db908f3e5d73

See more details on using hashes here.

File details

Details for the file asgi_sage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: asgi_sage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.10 Linux/5.3.0-7648-generic

File hashes

Hashes for asgi_sage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16a3e7d815d35049c345dfed275a6ab6d5633b3ea24ed4994b58a1b32f0aa479
MD5 a94660fe060779a2c86f4281c800d09b
BLAKE2b-256 706c68a52430142f066d235527a3ea0c1c986d8909c3d68bb52a4ea8234ea427

See more details on using hashes here.

Supported by

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