安全的认证

django-secure-auth的Python项目详细描述


Code HealthCodacyPython 2.7, 3.4+Current version on PyPiDownloads from PyPiLicense

通过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

屏幕截图

/screenshots/login-confirmation.jpg/screenshots/settings.jpg/screenshots/two-factor-configuration.jpg/screenshots/sms-settings.jpg

兼容性

  • Python:2.7
  • django:1.4、1.8、1.11

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java FloatingAction按钮与RecyclerView中的CardView重叠   java如何计算CardLayout中的卡数   从远程系统上传MySQL数据库并访问Java应用程序   java调用堆栈如何处理带或不带返回类型的递归?   Springboot中的java组计数聚集   java如何在javafx textarea中使用richtextfx   获取与Mockito相关的错误时出现Java问题   java如何将JaxRS响应转换为Wiremock响应   Hadoop集群java。net ConnectionException:连接被拒绝错误   java如何加载文件私有文件类型是pem   java在元空间中的提升和加载的类   如何将系统属性传递给从HTML启动的Java小程序   java如何从网页中获取值并在主类中使用它?安卓应用   java在春天,advisor和aspect之间有什么区别?   java如何检测文件是否已重命名?   java消息驱动Bean何时使用