基于zxcvbn python的django可翻译密码验证器。
django-zxcvbn-password-validator的Python项目详细描述
django zxcvbn密码验证器
django的可翻译密码验证器,基于zxcvbn python,可与pip一起使用。
使用django zxcvbn密码验证器创建用户
如果密码不够强,我们将提供错误信息,说明您需要执行的操作:
错误信息将被翻译成目标语言(甚至是ZxCVBN给出的仅使用英语的字符串):
如何使用
将它添加到您的需求中,并使用pip获取它。
django-zxcvbn-password-validator
然后一切都会在你的设置文件中发生。
在INSTALLED_APPS
中添加'django_zxcvbn_password_validator'
:
INSTALLED_APPS=[...'django_zxcvbn_password_validator']
修改AUTH_PASSWORD_VALIDATORS
:
AUTH_PASSWORD_VALIDATORS=[{'NAME':'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',},{'NAME':'django_zxcvbn_password_validator.ZxcvbnPasswordValidator',},...]
你可以选择单独使用zxcvbn,但我个人仍然使用django的UserAttributeSimilarityValidator
,
因为它与ZXCVBN整合用户信息似乎还存在一些问题(截至2018年6月)。
最后,您可以根据自己的喜好设置PASSWORD_MINIMAL_STRENGTH
(默认为2)。
低于此数字的密码将被拒绝:
# 0 too guessable: risky password. (guesses < 10^3)# 1 very guessable: protection from throttled online attacks. (guesses < 10^6)# 2 somewhat guessable: protection from unthrottled online attacks. (guesses < 10^8)# 3 safely unguessable: moderate protection from offline slow-hash scenario. (guesses < 10^10)# 4 very unguessable: strong protection from offline slow-hash scenario. (guesses >= 10^10)
翻译项目
此项目有多种语言版本。 如果您能做出贡献,我们将不胜感激 知道一种还没有的语言。
可用语言
这个软件是用英语开发的。其他可用语言为:
- [X]荷兰语感谢Thom Wiggers
- [X]法语感谢Pierre Sassoulas和Lionel Sausin
- [X]英语
贡献
测试
python manage.py test
覆盖范围
coverage run ./manage.py test coverage html # Open htmlcov/index.html in a navigator
皮棉
我们正在使用pre-commit
,它应该在提交期间处理linting。
pip install -r requirements_dev.txt pre-commit install
I18n
python manage.py makemessages # python manage.py createsuperuser ? (You need to login for rosetta) python manage.py runserver # Access http://localhost:8000/admin to login# Then go to http://localhost:8000/rosetta to translate python manage.py makemessages --no-obsolete --no-wrap