devise_zxcvbn 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 526ac3123d0a837cce7bdda0d90ebbfa8692c761
4
- data.tar.gz: 436b80dbb8c65bd293366e9164cc47d4259a57c4
3
+ metadata.gz: 791b541aa154d0db414fe1bca70493812f8ade6a
4
+ data.tar.gz: 6e4b67dcfdb05334fcd0bc7363e39226fd49cec1
5
5
  SHA512:
6
- metadata.gz: 343598df3d3ecd33f55432687038abb212197c5df67b4b9d1a41a9ab2e8b7407143d643a8997711bd217be6b49c00837dde469361a5bc96689f96ebf6a0a06a6
7
- data.tar.gz: 701baa70e9a24c088a5996fc524bae631806aff866dff26a306feb90bab54e651c70a8e27f7101e13f5b8682ed40ad35c261f5353a88f6983d2668d046263bc2
6
+ metadata.gz: f1d1fe199f8bbd077a31d34ad57c0db6fdef89a71c16082d41f8adea48eaf961ce491c93265f0441a8dace87f5a4bdd2f420e1b6287f7539c3953ad64a427f44
7
+ data.tar.gz: c5a5483ade3b0b88bdcabf8925f0af0cc22b9c8c9d414104a203cff65d853fabf0c55221e8eae3a0b33c000d2f4a226a5ba51b5d21cfe046b27829be72f6b710
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # devise_zxcvbn
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/devise_zxcvbn.png)](http://badge.fury.io/rb/devise_zxcvbn)
4
+
3
5
  Plugin for devise to reject weak passwords, using [zxcvbn-ruby](https://github.com/envato/zxcvbn-ruby) which is a ruby port of [zxcvbn: realistic password strength estimation](https://tech.dropbox.com/2012/04/zxcvbn-realistic-password-strength-estimation/).
4
6
  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 downscore passwords containing the email.
5
7
 
8
+ 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.
9
+
6
10
  ## Installation
7
11
 
8
12
  Add this line to your application's Gemfile:
@@ -16,19 +20,23 @@ Add this line to your application's Gemfile:
16
20
  devise :database_authenticatable, :zxcvbnable
17
21
  end
18
22
 
19
- Default parameters
23
+ ### Default parameters
24
+
25
+ A score of less than 3 is not recommended.
20
26
 
21
27
  Devise.setup do |config|
22
- config.min_password_score = 4 # 0, 1, 2, 3 or 4
28
+ config.min_password_score = 4
23
29
  end
24
30
 
25
31
  ### Error Message
26
32
 
33
+ Example error message, the `score` and `min_password_score` variables are also passed through if you need them.
34
+
27
35
  # config/locale/devise.en.yml
28
36
  en:
29
37
  errors:
30
38
  messages:
31
- weak_password: "not strong enough. It scored %{score}. It must score at least %{min_password_score}."
39
+ weak_password: "not strong enough. Consider adding a number, symbols or more letters to make it stronger"
32
40
 
33
41
 
34
42
  ## Contributing
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["matt@bitzesty.com"]
11
11
  spec.description = %q{It adds password strength checking via ruby-zxcvbn to reject weak passwords }
12
12
  spec.summary = %q{Devise plugin to reject weak passwords}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/bitzesty/devise_zxcvbn"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
data/lib/devise_zxcvbn.rb CHANGED
@@ -3,8 +3,25 @@ require "devise"
3
3
  require "zxcvbn"
4
4
 
5
5
  module Devise
6
- mattr_accessor :min_password_score
6
+
7
7
  @@min_password_score = 4
8
+
9
+ def self.min_password_score
10
+ @@min_password_score
11
+ end
12
+
13
+ def self.min_password_score=(score)
14
+ if score.is_a?(Integer) && (score >= 0 && score <=4)
15
+ if score >= 3
16
+ @@min_password_score = score
17
+ else
18
+ ::Rails.logger.warn "[devise_zxcvbn] A score of less than 3 is not recommended."
19
+ @@min_password_score = score
20
+ end
21
+ else
22
+ raise "The min_password_score must be an integer and between 0..4"
23
+ end
24
+ end
8
25
  end
9
26
 
10
27
  Devise.add_module :zxcvbnable, :model => "devise_zxcvbn/model"
@@ -1,3 +1,3 @@
1
1
  module DeviseZxcvbn
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_zxcvbn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ford
@@ -82,7 +82,7 @@ files:
82
82
  - lib/devise_zxcvbn.rb
83
83
  - lib/devise_zxcvbn/model.rb
84
84
  - lib/devise_zxcvbn/version.rb
85
- homepage: ''
85
+ homepage: https://github.com/bitzesty/devise_zxcvbn
86
86
  licenses:
87
87
  - MIT
88
88
  metadata: {}