Django management auth
Login to a Django application from a management command.
Installation
pip install django-management-auth
Then, add management_auth to INSTALLED_APPS.
Finally, add the required URLs:
# urls.py
urlpatterns += [path(".login-as", include("management_auth.urls"))]
Usage
Authentication happens using a short-lived signed URL, generated from a management command.
./manage.py login_as <username>
This will create a URL for <username>. By default, the URLs are valid for 60 seconds (configurable with --timeout).
Fully-qualified URLs
Where possible, URLs, are displayed fully-qualified, such that they can be quickly clicked to log in.
- To specify manually, use
MANAGEMENT_AUTH_BASE_URL - For Wagtail users,
WAGTAILADMIN_BASE_URLis used to create the URL. - For
django.contrib.sitesusers,SITE_IDis correctly considered
If no base URL is found, a relative path is shown.
Design considerations
- Tokens are only valid for a short amount of time, intended to prevent reuse / sharing.
- Tokens are signed URLs, rather than requiring a database table. This means the validation view is faster and more lightweight, and a database leak doesn't risk exposing sessions.
- Because tokens are signed, they can be used multiple times (however this is a bad idea)
Metadata
Release files for django-management-auth 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_management_auth-0.0.0.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_management_auth-0.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.3 kB
Release files / django_management_auth-0.0.0.tar.gz
| Download URL | django_management_auth-0.0.0.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9050f504bf24a0e31610ca73ccceab24bcae98197a87ccd2a49e7efa19b5461b
|
|
BLAKE2b-256 checksum How to use checksums |
a877cf5d04ec9acf2f56b0e14a44b6c9e3079480fd974db427a4172cb25ecff3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / django_management_auth-0.0.0-py3-none-any.whl
| Download URL | django_management_auth-0.0.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7044f3321dd3d74edb92a34326e680814382e0f5460d07cccd5e6c7466e0c5f3
|
|
BLAKE2b-256 checksum How to use checksums |
b48f30a7df33ad2ec9d9736dc82de6f66dd876c5c2d5fdcca3ebc72bb26f9457
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|