Skip to main content

Security Headers for asgi apps

Project description

🧙 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

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.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

asgi_sage-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asgi-sage-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 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.1.tar.gz
Algorithm Hash digest
SHA256 944c8f3b12548a2bf2b632476a2e2e73c482a52a0c169e38b553007158bdaff2
MD5 c93ae9d60b43c3d0d5f0c25d65d2e31d
BLAKE2b-256 9240cbe16ed1a19e71c8c4e6aa0750512ab39ef95f16da16ac1a3a283b4a8f69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asgi_sage-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e0bb24436612bafa00f4c79470e585246fe510c9b409b5e02aa22603fe0c3e2
MD5 6d6b76db985c8ae4e9d59af991fb30c6
BLAKE2b-256 5648183a6db3cbd53042170f8638b26165d97a68d69cce80510d1a3d93a4912f

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