Add captcha field for django admin's login page.
Project description
django-admin-safe-login
Add captcha field and rsa encryption password field for django admin's login page.
Install
pip install django-admin-safe-login
Usage
pro/settings.py
INSTALLED_APPS = [
...
'django_static_jquery3',
'django_secure_password_input',
'django_simple_tags',
'captcha',
'django_admin_safe_login',
...
]
CAPTCHA_IMAGE_SIZE = (100, 30) # required
DJANGO_ADMIN_SAFE_LOGIN_ENABLE_CAPTCHA = True # optional, default to True
DJANGO_ADMIN_SAFE_LOGIN_BACKGROUND_IMAGE = "django-admin-safe-login/img/example-background.jpg" # optional, default to no-image.
DJANGO_ADMIN_SAFE_LOGIN_BOX_MARGIN_RIGHT = "200px" # optional, default to auto
DJANGO_ADMIN_SAFE_LOGIN_BOX_MARGIN_LEFT = "auto" # optional, default to auto
DJANGO_ADMIN_SAFE_LOGIN_BOX_MARGIN_TOP = "100px" # optional, default to 100px
DJANGO_ADMIN_SAFE_LOGIN_BOX_MARGIN_BOTTOM = "100px" # optional, default to 100px
DJANGO_ADMIN_SAFE_LOGIN_TEMPLATE = "" # optional, default to "admin/login.html".
Note:
- Insert django_static_jquery3, django_secure_password_input, django-simple-tags, captcha and django_admin_safe_login into INSTALLED_APPS.
- Application django_static_jquery3 provides static jquery.js.
- Application django_secure_password_input provides rsa encryption and decryption function for password field.
- Application django_admin_safe_login provides all functions about safe login.
- Application captcha provides image captcha functions.
- Application django-simple-tags provides custom template tags used in our admin/login.html.
- Configuration item CAPTCHA_IMAGE_SIZE is required, and must set to (100, 30) so that it will not break the display style. If you want other size image, you have to rewrite some css code.
- Configurations about password RSA encryption, see details at https://pypi.org/project/django-secure-password-input/.
- Configurations about captcha, see detail at https://pypi.org/project/django-simple-captcha/.
- Configurations about password reset, see detail at https://docs.djangoproject.com/en/3.0/ref/contrib/admin/ (search: Adding a password reset feature).
pro/urls.py
from django.urls import path
from django.urls import include
urlpatterns = [
...
path('captcha/', include("captcha.urls")),
...
]
Note:
- Include captcha.urls is required so that the captcha image can be displayed.
Changes about admin/login.html
We have override some part of admin/login.html. But the admin/login.html content may change in future releases. So you should known what part is overrided.
- Our new admin/login.html extends from system's admin/login.html.
- We override the extrastyle block to add extra js and css.
- The function adding background image and changing login box position is implemented in our new extrastyle block.
- We override the whole content block.
- We copied the whole content block from django's default admin/login.html.
- We added blocks inside content block: form, form-row-username, from-row-password, form-row-extra, form-row-captcha, password-reset-url, before-submit-row, submit-row, after-submit-row.
Releases
v0.3.0 2020/05/20
- Add background image setting.
- Add login box position setting.
- Use admin/login.html override instead of creating a new template.
- Fix document.
- Fix translation.
- Fix setup.py problem that include demo and example code in the final package.
v0.2.0 2020/03/07
- Add rsa encryption and decrption functions for password field.
- Fix requirements.txt missing django-static-jquery3 problem.
v0.1.0 2020/03/06
- First release.
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
django-admin-safe-login-0.3.0.tar.gz
(287.8 kB
view details)
File details
Details for the file django-admin-safe-login-0.3.0.tar.gz
.
File metadata
- Download URL: django-admin-safe-login-0.3.0.tar.gz
- Upload date:
- Size: 287.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b45d9b72867347bf31346399f8cbb85fc3eaf80551964bb23caa16e4ef832fa |
|
MD5 | 7ed8b14a200b70b11c95efcae4354472 |
|
BLAKE2b-256 | dbfdbf6c7247c1d06343f2509436cbe19478376478f68e9b48bad7486f1f90d2 |