百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

devise_zxcvbn

> 编程语言
开源

使用 zxcvbn 设计插件来拒绝弱密码

199 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

使用 zxcvbn 设计插件来拒绝弱密码

devise_zxcvbn

Plugin for devise to reject weak passwords, using zxcvbn-rb which is a ruby port of zxcvbn: realistic password strength estimation.

The user's password will be rejected if the score is below 4 by default. It also uses the email as user input to zxcvbn, to reject passwords containing parts of the email (if using zxcvbn.js on the frontend you should also do this to get the same score).

The scores 0, 1, 2, 3 or 4 are given when the estimated crack time (seconds) is less than 10**2, 10**4, 10**6, 10**8, Infinity.

Installation

Add this line to your application's Gemfile:

ruby
gem 'devise_zxcvbn'

Configuration

…

Default parameters

A score of less than 3 is not recommended.

ruby
# config/initializers/devise.rb
Devise.setup do |config|
  config.min_password_score = 4
end

Error Message

The default error message:

yaml
"not strong enough. It scored %{score}. It must score at least %{min_password_score}."

You can customize this error message modifying the devise YAML file.

The crack_time_display, feedback, score and min_password_score variables are passed through if you need them.

yaml
# config/locales/devise.en.yml
en:
  errors:
    messages:
      weak_password: "not strong enough. Consider adding a number, symbols or more letters to make it stronger."

Skipping password complexity validation

To turn off password complexity validation for certain conditions, you could implement a concern (or similar) that overloads skip_password_complexity?:

ruby
def skip_password_complexity?
  true
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add test coverage for the feature, We use rspec for this purpose
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

devise_zxcvbn is Copyright © 2013 Bit Zesty. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About Bit Zesty

devise_zxcvbn is maintained by Bit Zesty Limited. The names and logos for Bit Zesty are trademarks of Bit Zesty Limited.

See our other projects or hire us to design, develop, and support your product or service.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言