pwned 1.1.0 → 1.2.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +16 -12
- data/Rakefile +5 -0
- data/docs/NotPwnedValidator.html +425 -0
- data/docs/Pwned.html +513 -0
- data/docs/Pwned/Error.html +149 -0
- data/docs/Pwned/Password.html +925 -0
- data/docs/Pwned/TimeoutError.html +152 -0
- data/docs/PwnedValidator.html +192 -0
- data/docs/_index.html +162 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +499 -0
- data/docs/file.README.html +292 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +292 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +115 -0
- data/docs/top-level-namespace.html +112 -0
- data/lib/locale/en.yml +1 -1
- data/lib/pwned.rb +34 -3
- data/lib/pwned/error.rb +11 -0
- data/lib/pwned/not_pwned_validator.rb +118 -0
- data/lib/pwned/password.rb +60 -5
- data/lib/pwned/version.rb +3 -1
- data/pwned.gemspec +1 -0
- metadata +37 -3
- data/lib/pwned/pwned_validator.rb +0 -41
data/lib/pwned/version.rb
CHANGED
data/pwned.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwned
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.12
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.12
|
69
83
|
description: Tools to use the Pwned Passwords API.
|
70
84
|
email:
|
71
85
|
- philnash@gmail.com
|
@@ -84,11 +98,31 @@ files:
|
|
84
98
|
- Rakefile
|
85
99
|
- bin/console
|
86
100
|
- bin/setup
|
101
|
+
- docs/NotPwnedValidator.html
|
102
|
+
- docs/Pwned.html
|
103
|
+
- docs/Pwned/Error.html
|
104
|
+
- docs/Pwned/Password.html
|
105
|
+
- docs/Pwned/TimeoutError.html
|
106
|
+
- docs/PwnedValidator.html
|
107
|
+
- docs/_index.html
|
108
|
+
- docs/class_list.html
|
109
|
+
- docs/css/common.css
|
110
|
+
- docs/css/full_list.css
|
111
|
+
- docs/css/style.css
|
112
|
+
- docs/file.README.html
|
113
|
+
- docs/file_list.html
|
114
|
+
- docs/frames.html
|
115
|
+
- docs/index.html
|
116
|
+
- docs/js/app.js
|
117
|
+
- docs/js/full_list.js
|
118
|
+
- docs/js/jquery.js
|
119
|
+
- docs/method_list.html
|
120
|
+
- docs/top-level-namespace.html
|
87
121
|
- lib/locale/en.yml
|
88
122
|
- lib/pwned.rb
|
89
123
|
- lib/pwned/error.rb
|
124
|
+
- lib/pwned/not_pwned_validator.rb
|
90
125
|
- lib/pwned/password.rb
|
91
|
-
- lib/pwned/pwned_validator.rb
|
92
126
|
- lib/pwned/version.rb
|
93
127
|
- pwned.gemspec
|
94
128
|
homepage: https://github.com/philnash/pwned
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class PwnedValidator < ActiveModel::EachValidator
|
4
|
-
# We do not want to break customer sign-up process when the service is down.
|
5
|
-
DEFAULT_ON_ERROR = :valid
|
6
|
-
DEFAULT_THRESHOLD = 0
|
7
|
-
|
8
|
-
def validate_each(record, attribute, value)
|
9
|
-
begin
|
10
|
-
pwned_check = Pwned::Password.new(value, request_options)
|
11
|
-
if pwned_check.pwned_count > threshold
|
12
|
-
record.errors.add(attribute, :pwned, options.merge(count: pwned_check.pwned_count))
|
13
|
-
end
|
14
|
-
rescue Pwned::Error => error
|
15
|
-
case on_error
|
16
|
-
when :invalid
|
17
|
-
record.errors.add(attribute, :pwned_error, options.merge(message: options[:error_message]))
|
18
|
-
when :valid
|
19
|
-
# Do nothing, consider the record valid
|
20
|
-
when Proc
|
21
|
-
on_error.call(record, error)
|
22
|
-
else
|
23
|
-
raise
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def on_error
|
29
|
-
options[:on_error] || DEFAULT_ON_ERROR
|
30
|
-
end
|
31
|
-
|
32
|
-
def request_options
|
33
|
-
options[:request_options] || {}
|
34
|
-
end
|
35
|
-
|
36
|
-
def threshold
|
37
|
-
threshold = options[:threshold] || DEFAULT_THRESHOLD
|
38
|
-
raise TypeError, "PwnedValidator option 'threshold' must be of type Integer" unless threshold.is_a? Integer
|
39
|
-
threshold
|
40
|
-
end
|
41
|
-
end
|