Skip to main content

An admin page with a checkbox to enable the Django Debug Toolbar.

Project description

Debug Toolbar Checkbox

Demo

Install

$ pip install debug_toolbar_checkbox

In settings.py, add debug_toolbar_checkbox before django admin:

INSTALLED_APPS = [
    "debug_toolbar",
    "debug_toolbar_checkbox",
    "django.contrib.admin",
    ...,
]

In settings.py set a DEBUG_TOOLBAR_SETTINGS, or derive it from SECRET_KEY:

DEBUG_TOOLBAR_SECRET = sha256(b"djdt" + SECRET_KEY.encode("UTF-8")).hexdigest()

In settings.py configure the Debug Toolbar to check the secret in the cookie:

DEBUG_TOOLBAR_CONFIG = {
    "SHOW_TOOLBAR_CALLBACK": lambda request: DEBUG_TOOLBAR_SECRET in request.headers.get("cookie", "")
}

In urls.py add this before the path("admin/"):

path("admin/pages/", include("debug_toolbar_checkbox.urls")),

Security

The activation is governed by the presence of a secret in a cookie. The cookie is set by some JavaScript (static file, publicly available). But the secret is only written in the admin page as a data attribute. The admin page is only accessible to superusers, so only superusers can query the page containing the secret.

If you're not OK with my sha256/concat to derive a new secret, feel free to replace it with a truly random secret.

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

django_debug_toolbar_checkbox-0.1.1.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_debug_toolbar_checkbox-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file django_debug_toolbar_checkbox-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django_debug_toolbar_checkbox-0.1.1.tar.gz
Algorithm Hash digest
SHA256 70ed5c5a0d1980e93de78e16fd752ecf4e724492a604d3a4cf41d9cac49010a0
MD5 f143bda75404798a61695ae47ae57f70
BLAKE2b-256 531e158812fa1979a828c6a902aef55b7c25961eb11a96a8cd52d8d336af3ae6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_debug_toolbar_checkbox-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2853bfc9990ea317f41bbe0298d2dcbea93e66c021d45be4be9d6f63d3b4ed1f
MD5 c25afa139791ecadc9ae0d93db94e91f
BLAKE2b-256 e323526326daf07344307ab1aeacc692ce98c724b0150d890b991af9ae352887

See more details on using hashes here.

Supported by

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