Skip to main content

Falcon middleware for sanity-checking that HTTPS was used for the request.

Project description

The falcon-require-https package provides a middleware component for sanity-checking that the incoming request was received over HTTPS. While the web server is primarily responsibile for enforcing the HTTPS protocol, misconfiguration is still a leading cause of security vulnerabilities, and so it can be helpful to perform certain additional checks, such as this one, within the application layer itself.

Installation

$ pip install falcon-require-https

Usage

The RequireHTTPS middleware class verifies each incoming request. To use it, simply pass an instance to the falcon.API() initializer:

from falcon_require_https import RequireHTTPS

app = falcon.API(middleware=[RequireHTTPS()])

At least one of the following sources must indicate the use of HTTPS:

  • The schema of the requested URL

  • The X-Forwarded-Proto header

  • The Forwarded header (only the first hop is checked)

Otherwise, an instance of falcon.HTTPBadRequest is raised.

Caution

This middleware is not meant to replace proper security controls in your web server or load balancer. It is simply meant as a final backstop to guard against inadvertent misconfiguration at the networking layer.

Credits

This middleware component is based on paul291’s original proof of concept, which was originally submitted as a PR to the falconry/falcon repo.

About Falcon

Falcon is a bare-metal Python web framework for building lean and mean cloud APIs and app backends. It encourages the REST architectural style, and tries to do as little as possible while remaining highly effective.

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

falcon-require-https-0.1.0.dev0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

falcon_require_https-0.1.0.dev0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file falcon-require-https-0.1.0.dev0.tar.gz.

File metadata

File hashes

Hashes for falcon-require-https-0.1.0.dev0.tar.gz
Algorithm Hash digest
SHA256 fed87be865232a154735c9d1c88c5bb8cc1811626b74703d78ebb613b8416f64
MD5 173fd65622ed5ff78419a3c966639a60
BLAKE2b-256 322504fc644b1403fe5876287e82ca624efc122e2c42465727f4033de96fe574

See more details on using hashes here.

File details

Details for the file falcon_require_https-0.1.0.dev0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for falcon_require_https-0.1.0.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ff65fd447ed5334d71a97d08004b4ec3896f8b9614e6a2ab3862fa161d163357
MD5 6d24384ceba78a2f8895043e92c588b5
BLAKE2b-256 dc25fe87c174ade06f3e6918176d0d14e615673db84a9be4df519ebf92e27c2b

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