nobspw 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2822386df873b457c238d992dc10557886e06852ff13d3d82ff83aa678d399d5
4
- data.tar.gz: 514207c17b7aa170f7e037953ff48dde07c884a86fbba822277e317506d9738f
3
+ metadata.gz: 50bde3af21d4ae1a914fdf29d97c7cd4636f9045d12053b19b03b10562432200
4
+ data.tar.gz: bb15b53c7660e771fd4d0d430be1882186d11515662d1ffe9f221478f4df0013
5
5
  SHA512:
6
- metadata.gz: 3c22655a227cddafed368bf1fe64ae30825106ebf50f3c5833868a4cfec9ec077c784d2c62bc78860d6d30be0a169e0dab209920e7424e87e4ee6ad854bcdff6
7
- data.tar.gz: ee59f029dc465da9adf867c939c96d62a03a888f54256a6c22256efc666a1bc5b54acdc20a2f9b9746af6a777c305d8eac901a6a46ea087e89468b2399af1cf5
6
+ metadata.gz: f8688c43975ea97d01f0bb39d8213dd221f7e4ec1022cba7b068e079c7e6213a826dc36949b90582ca2e3e8a23b9f7e9388904357c2166deaf5ef614ea646f83
7
+ data.tar.gz: 1c2f2a8835ab93d53bcb187bc7eb86123280d2c831114a7c5f26822708ee44ac1d20ac41c797a8a9b0d57543a44a0de3c3bcb1104a6f4cbea2c8c4033e9db871
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /coverage/
11
11
  /spec/examples.txt
12
12
  *.gem
13
+ .byebug_history
data/README.md CHANGED
@@ -61,7 +61,7 @@ Optionally, you can configure some options:
61
61
  config.dictionary_path = 'path/to/dictionary.txt'
62
62
  config.grep_path = '/usr/bin/grep'
63
63
  config.domain_name = 'mywebsitedomain.com' # it is recommended you configure this
64
- config.blacklist = ['this_password_is_not_allowed']
64
+ config.blacklist = ['this_password_is_not_allowed', /password/]
65
65
  end
66
66
  ```
67
67
 
@@ -1,6 +1,7 @@
1
1
  class ActiveModel::Validations::PasswordValidator < ActiveModel::EachValidator
2
2
  DEFAULT_ERROR_MESSAGES = {
3
3
  name_included_in_password: 'is too similar to your name',
4
+ username_included_in_password: 'is too similar to your username',
4
5
  email_included_in_password: 'is too similar to your email',
5
6
  domain_included_in_password: 'is too similar to this domain name',
6
7
  password_too_short: 'is too short',
@@ -26,7 +26,6 @@ module NOBSPW
26
26
 
27
27
  def check_password
28
28
  @weak_password_reasons = []
29
-
30
29
  NOBSPW.configuration.validation_methods.each do |method|
31
30
  if send("#{method}")
32
31
  @weak_password_reasons << method.to_s.sub(/\?$/, '').to_sym
@@ -2,6 +2,7 @@ module NOBSPW
2
2
  module ValidationMethods
3
3
  DEFAULT_VALIDATION_METHODS = %i(password_empty?
4
4
  name_included_in_password?
5
+ username_included_in_password?
5
6
  email_included_in_password?
6
7
  domain_included_in_password?
7
8
  password_too_short?
@@ -24,6 +25,12 @@ module NOBSPW
24
25
  words_included_in_password?(words)
25
26
  end
26
27
 
28
+ def username_included_in_password?
29
+ return nil unless @username
30
+ words = remove_word_separators(@username).split(' ')
31
+ words_included_in_password?(words)
32
+ end
33
+
27
34
  def email_included_in_password?
28
35
  return nil unless @email
29
36
  words = remove_word_separators(email_without_extension(@email)).split(' ')
@@ -40,7 +47,16 @@ module NOBSPW
40
47
 
41
48
  def password_not_allowed?
42
49
  return nil unless NOBSPW.configuration.blacklist
43
- NOBSPW.configuration.blacklist.include?(@password)
50
+
51
+ NOBSPW.configuration.blacklist.each do |expression|
52
+ if expression.is_a?(Regexp)
53
+ return true if @password.match?(expression)
54
+ else
55
+ return true if expression.to_s == @password
56
+ end
57
+ end
58
+
59
+ false
44
60
  end
45
61
 
46
62
  def password_too_short?
@@ -1,3 +1,3 @@
1
1
  module NOBSPW
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "guard-rspec", "~> 4.7.3"
30
30
  spec.add_development_dependency "activemodel", "~> 5.0"
31
31
  spec.add_development_dependency "i18n", "~> 0.8.1"
32
+ spec.add_development_dependency "byebug"
32
33
 
33
34
  if RUBY_PLATFORM =~ /darwin/
34
35
  spec.add_development_dependency 'ruby_gntp', "~> 0.3.4"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nobspw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Mercier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-27 00:00:00.000000000 Z
11
+ date: 2019-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.8.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: byebug
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: ruby_gntp
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
210
  version: '0'
197
211
  requirements: []
198
212
  rubyforge_project:
199
- rubygems_version: 2.7.3
213
+ rubygems_version: 2.7.6
200
214
  signing_key:
201
215
  specification_version: 4
202
216
  summary: No Bullshit Password strength checker