安全的认证
django-secure-auth的Python项目详细描述
通过totp/sms/codes/question提供安全认证的模块。 当登录尝试失败时,登录受IP范围和验证码保护。
演示安装:
$ sudo apt-get install -y virtualenvwrapper redis-server git python-dev || brew install pyenv-virtualenvwrapper redis git geoip $ source /usr/share/virtualenvwrapper/virtualenvwrapper.sh ||source /usr/local/bin/virtualenvwrapper.sh $ mkvirtualenv django-secure-auth $ workon django-secure-auth $ git clone --depth 1 https://github.com/gotlium/django-secure-auth.git $ cd django-secure-auth $ pip install -r requirements.txt $ python setup.py develop $ cd demo $ pip install -r requirements.txt $ python manage.py syncdb --noinput $ python manage.py migrate --noinput $ python manage.py createsuperuser --username admin --email admin@local.host $ wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz $ gunzip GeoLiteCity.dat.gz $ mkdir -p /usr/share/geoip/; mv GeoLiteCity.dat /usr/share/geoip/ $ cd ../
打开设置:
$ vim demo/settings.py
将AUTH_SMS_BACKEND_AUTH中的twilio凭据替换为演示帐户设置,或将sms force更改为false。
运行redis服务器和芹菜守护进程(或从INSTALLED_APPS中删除'djceleri'):
$ make run_redis $ make run_celery
运行测试服务器:
$ make run_server
现在您可以打开https://127.0.0.1:8000/accounts/register/并注册 新建帐户并设置所有可用的身份验证方法。
注意:激活链接将输出到控制台。
crontab
使用totp auth方法时,请更新服务器时间。 如果您的服务器时间超过实时时间,则无法通过身份验证程序应用程序对用户进行身份验证。 您可以运行ntpd客户端,或按cron作业更新服务器上的时间:
SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games MAILTO=root@localhost # Update time 0 */6 * * * ntpdate ntp.ubuntu.com >& /dev/null
屏幕截图
兼容性
- Python:2.7
- django:1.4、1.8、1.11