wagtail的双因素认证
wagtail-2fa的Python项目详细描述
这个django应用程序添加了对wagtail的双因素身份验证。幕后 它使用django-otp支持基于时间的一次性密码(totp)。这个 允许您使用各种应用程序,如authy、google authenticator或 1密码。
安装
pip install wagtail-2fa
然后将以下行添加到django中的INSTALLED_APPS列表中 设置:
INSTALLED_APPS=[# ...'wagtail_2fa','django_otp','django_otp.plugins.otp_totp',# ...]
迁移数据库:
python manage.py migrate
接下来将所需的中间件添加到MIDDLEWARE。它应该来了 认证中间件之后:
MIDDLEWARE=[# .. other middleware# 'django.contrib.auth.middleware.AuthenticationMiddleware','wagtail_2fa.middleware.VerifyUserMiddleware',# 'wagtail.core.middleware.SiteMiddleware',# .. other middleware]
设置
以下设置可用(通过Django设置设置):
- ^{tt3}$ (default ^{tt4}$): When set to True all staff, superuser and other users with access to the Wagtail Admin site are forced to login using two factor authentication.
- ^{tt5}$ (default: ^{tt6}$): The uWSGI mount point that Wagtail is running at. Ex. ^{tt7}$
- ^{tt8}$ (default: ^{tt4}$): The issuer name to identify which site is which in your authenticator app. If not set and ^{tt10}$ is defined it uses this. sets ^{tt11}$ under the hood.
沙箱
首先用python 3.6.1创建一个新的virtualenv并激活它。那就跑吧 以下命令:
- make sandbox
然后您可以访问http://localhost:8000/admin/并使用以下命令登录 凭证:
- E-mail: superuser@example.com
- Password: testing