Login to a Django application from a management command
Project description
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_URL
is used to create the URL. - For
django.contrib.sites
users,SITE_ID
is 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_management_auth-0.0.0.tar.gz
.
File metadata
- Download URL: django_management_auth-0.0.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9050f504bf24a0e31610ca73ccceab24bcae98197a87ccd2a49e7efa19b5461b |
|
MD5 | ab1d2b01a0ecc99d7e2e9f54c0ffc6e5 |
|
BLAKE2b-256 | a877cf5d04ec9acf2f56b0e14a44b6c9e3079480fd974db427a4172cb25ecff3 |
Provenance
File details
Details for the file django_management_auth-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_management_auth-0.0.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7044f3321dd3d74edb92a34326e680814382e0f5460d07cccd5e6c7466e0c5f3 |
|
MD5 | 995defe822454f136cc9adfdc61d7aac |
|
BLAKE2b-256 | b48f30a7df33ad2ec9d9736dc82de6f66dd876c5c2d5fdcca3ebc72bb26f9457 |