Skip to main content

django-moat

django-moat is a mini-app adds an additional layer of authentication via HTTP Basic Auth. It’s primary use case is to prevent access staging, development, or otherwise private sites on the public internet. It is equivalent to configuring Basic Auth on your webserver (Apache, nginx) but works in environments where that is not possible (heroku).

Installation

From PyPi

pip install django-moat

To install from source

pip install -e git+https://github.com/amrox/django-moat#egg=django-moat

Configuration

Add moat.middleware.MoatMiddleware to your MIDDLEWARE_CLASSES:

MIDDLEWARE_CLASSES = (
    # Existing middleware classes
    "moat.middleware.MoatMiddleware",
)

moat has several configuration variable you may put in your settings.py

MOAT_ENABLED

Enable or disable moat. (True or False)

MOAT_ENABLED = True

HTTP_AUTH_REALM

Set Basic Auth Realm

HTTP_AUTH_REALM = ‘App Staging’

MOAT_ALWAYS_ALLOW_VIEWS

A list of views to allow through moat

MOAT_ALWAYS_ALLOW_VIEWS = [‘myapp.views.home’]

MOAT_ALWAYS_ALLOW_MODULES

A list of modules to allow through moat

MOAT_ALWAYS_ALLOW_MODULES = [‘oauth_provider.views’]

MOAT_ALLOW_ADMIN

Let the admin site through moat. Default: False.

MOAT_ALLOW_ADMIN = True

MOAT_DEBUG_DISABLE_HTTPS

Disable HTTPS. For testing purposes only. Don’t ship with this on.

MOAT_DEBUG_DISABLE_HTTPS = True

Finally you may want to set the SESSION_EXPIRE_AT_BROWSER_CLOSE setting.

Usage

Your site now requires that your authenticate with a staff-level user before accessing any non-whitelisted view. It is recommended that your add a dedicate staff-level user in the django admin for moat authentication.

By default, the admin views will be blocked by moat. You’ll either need to create a user with django-admin.py, or set MOAT_ALLOW_ADMIN to True.

Acknowledgements

Code borrowed from:

Thanks to Ryan Balfanz for suggesting the name moat.

Metadata

Release files for django-moat 0.1.1

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

Source distribution (sdist)

Source distribution for django-moat 0.1.1
File Size Uploaded Provenance Actions
django-moat-0.1.1.tar.gz 4.5 kB Without provenance Details for django-moat-0.1.1.tar.gz

Release files / django-moat-0.1.1.tar.gz

Download URL django-moat-0.1.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6764e2c3d927d734d848f76af39faa75152afb2bb21245170f3fcea3fa4eebf1
BLAKE2b-256 checksum
How to use checksums
8d59b58760b2cd602d015c60beafaea7cf9d72d76c77b522355c29135ccc9db8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-moat 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

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