pwned 1.2.0 → 2.1.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/.travis.yml +13 -9
- data/.yardopts +1 -0
- data/CHANGELOG.md +70 -15
- data/README.md +139 -10
- data/bin/pwned +52 -0
- data/lib/pwned.rb +22 -6
- data/lib/pwned/hashed_password.rb +35 -0
- data/lib/pwned/not_pwned_validator.rb +17 -3
- data/lib/pwned/password.rb +11 -96
- data/lib/pwned/password_base.rb +133 -0
- data/lib/pwned/version.rb +1 -1
- data/pwned.gemspec +11 -2
- metadata +25 -30
- data/docs/NotPwnedValidator.html +0 -425
- data/docs/Pwned.html +0 -513
- data/docs/Pwned/Error.html +0 -149
- data/docs/Pwned/Password.html +0 -925
- data/docs/Pwned/TimeoutError.html +0 -152
- data/docs/PwnedValidator.html +0 -192
- data/docs/_index.html +0 -162
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -499
- data/docs/file.README.html +0 -292
- data/docs/file_list.html +0 -56
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -292
- data/docs/js/app.js +0 -248
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -115
- data/docs/top-level-namespace.html +0 -112
data/docs/NotPwnedValidator.html
DELETED
@@ -1,425 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
Class: NotPwnedValidator
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.12
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "NotPwnedValidator";
|
19
|
-
relpath = '';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="_index.html">Index (N)</a> »
|
40
|
-
|
41
|
-
|
42
|
-
<span class="title">NotPwnedValidator</span>
|
43
|
-
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<div id="search">
|
47
|
-
|
48
|
-
<a class="full_list_link" id="class_list_link"
|
49
|
-
href="class_list.html">
|
50
|
-
|
51
|
-
<svg width="24" height="24">
|
52
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
-
</svg>
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div id="content"><h1>Class: NotPwnedValidator
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
<dl>
|
70
|
-
<dt>Inherits:</dt>
|
71
|
-
<dd>
|
72
|
-
<span class="inheritName">ActiveModel::EachValidator</span>
|
73
|
-
|
74
|
-
<ul class="fullTree">
|
75
|
-
<li>Object</li>
|
76
|
-
|
77
|
-
<li class="next">ActiveModel::EachValidator</li>
|
78
|
-
|
79
|
-
<li class="next">NotPwnedValidator</li>
|
80
|
-
|
81
|
-
</ul>
|
82
|
-
<a href="#" class="inheritanceTree">show all</a>
|
83
|
-
|
84
|
-
</dd>
|
85
|
-
</dl>
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
<dl>
|
98
|
-
<dt>Defined in:</dt>
|
99
|
-
<dd>lib/pwned/not_pwned_validator.rb</dd>
|
100
|
-
</dl>
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
<h2>Overview</h2><div class="docstring">
|
105
|
-
<div class="discussion">
|
106
|
-
|
107
|
-
<p>An <code>ActiveModel</code> validator to check passwords against the Pwned
|
108
|
-
Passwords API.</p>
|
109
|
-
|
110
|
-
|
111
|
-
</div>
|
112
|
-
</div>
|
113
|
-
<div class="tags">
|
114
|
-
|
115
|
-
<div class="examples">
|
116
|
-
<p class="tag_title">Examples:</p>
|
117
|
-
|
118
|
-
|
119
|
-
<p class="example_title"><div class='inline'>
|
120
|
-
<p>Validate a password on a <code>User</code> model with the default options.</p>
|
121
|
-
</div></p>
|
122
|
-
|
123
|
-
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'><</span> <span class='const'>ApplicationRecord</span>
|
124
|
-
<span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='kw'>true</span>
|
125
|
-
<span class='kw'>end</span></code></pre>
|
126
|
-
|
127
|
-
|
128
|
-
<p class="example_title"><div class='inline'>
|
129
|
-
<p>Validate a password on a <code>User</code> model with a custom error
|
130
|
-
message.</p>
|
131
|
-
</div></p>
|
132
|
-
|
133
|
-
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'><</span> <span class='const'>ApplicationRecord</span>
|
134
|
-
<span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>message:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>has been pwned %{count} times</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
135
|
-
<span class='kw'>end</span></code></pre>
|
136
|
-
|
137
|
-
|
138
|
-
<p class="example_title"><div class='inline'>
|
139
|
-
<p>Validate a password on a <code>User</code> model that allows the password
|
140
|
-
to have been breached once.</p>
|
141
|
-
</div></p>
|
142
|
-
|
143
|
-
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'><</span> <span class='const'>ApplicationRecord</span>
|
144
|
-
<span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>threshold:</span> <span class='int'>1</span> <span class='rbrace'>}</span>
|
145
|
-
<span class='kw'>end</span></code></pre>
|
146
|
-
|
147
|
-
|
148
|
-
<p class="example_title"><div class='inline'>
|
149
|
-
<p>Validate a password on a <code>User</code> model, handling API errors in
|
150
|
-
various ways</p>
|
151
|
-
</div></p>
|
152
|
-
|
153
|
-
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'><</span> <span class='const'>ApplicationRecord</span>
|
154
|
-
<span class='comment'># The record is marked as invalid on network errors
|
155
|
-
</span> <span class='comment'># (error message "could not be verified against the past data breaches".)
|
156
|
-
</span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:invalid</span> <span class='rbrace'>}</span>
|
157
|
-
|
158
|
-
<span class='comment'># The record is marked as invalid on network errors with custom error.
|
159
|
-
</span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:invalid</span><span class='comma'>,</span> <span class='label'>error_message:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>might be pwned</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
160
|
-
|
161
|
-
<span class='comment'># An error is raised on network errors.
|
162
|
-
</span> <span class='comment'># This means that `record.valid?` will raise `Pwned::Error`.
|
163
|
-
</span> <span class='comment'># Not recommended to use in production.
|
164
|
-
</span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:raise_error</span> <span class='rbrace'>}</span>
|
165
|
-
|
166
|
-
<span class='comment'># Call custom proc on error. For example, capture errors in Sentry,
|
167
|
-
</span> <span class='comment'># but do not mark the record as invalid.
|
168
|
-
</span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span>
|
169
|
-
<span class='label'>on_error:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='const'>Raven</span><span class='period'>.</span><span class='id identifier rubyid_capture_exception'>capture_exception</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
170
|
-
<span class='rbrace'>}</span>
|
171
|
-
<span class='kw'>end</span></code></pre>
|
172
|
-
|
173
|
-
</div>
|
174
|
-
|
175
|
-
<p class="tag_title">Since:</p>
|
176
|
-
<ul class="since">
|
177
|
-
|
178
|
-
<li>
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
<div class='inline'>
|
185
|
-
<p>1.2.0</p>
|
186
|
-
</div>
|
187
|
-
|
188
|
-
</li>
|
189
|
-
|
190
|
-
</ul>
|
191
|
-
|
192
|
-
</div><div id="subclasses">
|
193
|
-
<h2>Direct Known Subclasses</h2>
|
194
|
-
<p class="children"><span class='object_link'><a href="PwnedValidator.html" title="PwnedValidator (class)">PwnedValidator</a></span></p>
|
195
|
-
</div>
|
196
|
-
|
197
|
-
<h2>Constant Summary</h2>
|
198
|
-
<dl class="constants">
|
199
|
-
|
200
|
-
<dt id="DEFAULT_ON_ERROR-constant" class="">DEFAULT_ON_ERROR =
|
201
|
-
<div class="docstring">
|
202
|
-
<div class="discussion">
|
203
|
-
|
204
|
-
<p>The default behaviour of this validator in the case of an API failure. The
|
205
|
-
default will mean that if the API fails the object will not be marked
|
206
|
-
invalid.</p>
|
207
|
-
|
208
|
-
|
209
|
-
</div>
|
210
|
-
</div>
|
211
|
-
<div class="tags">
|
212
|
-
|
213
|
-
<p class="tag_title">Since:</p>
|
214
|
-
<ul class="since">
|
215
|
-
|
216
|
-
<li>
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
<div class='inline'>
|
223
|
-
<p>1.2.0</p>
|
224
|
-
</div>
|
225
|
-
|
226
|
-
</li>
|
227
|
-
|
228
|
-
</ul>
|
229
|
-
|
230
|
-
</div>
|
231
|
-
</dt>
|
232
|
-
<dd><pre class="code"><span class='symbol'>:valid</span></pre></dd>
|
233
|
-
|
234
|
-
<dt id="DEFAULT_THRESHOLD-constant" class="">DEFAULT_THRESHOLD =
|
235
|
-
<div class="docstring">
|
236
|
-
<div class="discussion">
|
237
|
-
|
238
|
-
<p>The default threshold for whether a breach is considered pwned. The default
|
239
|
-
is 0, so any password that appears in a breach will mark the record as
|
240
|
-
invalid.</p>
|
241
|
-
|
242
|
-
|
243
|
-
</div>
|
244
|
-
</div>
|
245
|
-
<div class="tags">
|
246
|
-
|
247
|
-
<p class="tag_title">Since:</p>
|
248
|
-
<ul class="since">
|
249
|
-
|
250
|
-
<li>
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
<div class='inline'>
|
257
|
-
<p>1.2.0</p>
|
258
|
-
</div>
|
259
|
-
|
260
|
-
</li>
|
261
|
-
|
262
|
-
</ul>
|
263
|
-
|
264
|
-
</div>
|
265
|
-
</dt>
|
266
|
-
<dd><pre class="code"><span class='int'>0</span></pre></dd>
|
267
|
-
|
268
|
-
</dl>
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
<h2>
|
278
|
-
Instance Method Summary
|
279
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
280
|
-
</h2>
|
281
|
-
|
282
|
-
<ul class="summary">
|
283
|
-
|
284
|
-
<li class="public ">
|
285
|
-
<span class="summary_signature">
|
286
|
-
|
287
|
-
<a href="#validate_each-instance_method" title="#validate_each (instance method)">#<strong>validate_each</strong>(record, attribute, value) ⇒ Object </a>
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
</span>
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
<span class="summary_desc"><div class='inline'>
|
302
|
-
<p>Validates the <code>value</code> against the Pwned Passwords API.</p>
|
303
|
-
</div></span>
|
304
|
-
|
305
|
-
</li>
|
306
|
-
|
307
|
-
|
308
|
-
</ul>
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
<div id="instance_method_details" class="method_details_list">
|
315
|
-
<h2>Instance Method Details</h2>
|
316
|
-
|
317
|
-
|
318
|
-
<div class="method_details first">
|
319
|
-
<h3 class="signature first" id="validate_each-instance_method">
|
320
|
-
|
321
|
-
#<strong>validate_each</strong>(record, attribute, value) ⇒ <tt>Object</tt>
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
</h3><div class="docstring">
|
328
|
-
<div class="discussion">
|
329
|
-
|
330
|
-
<p>Validates the <code>value</code> against the Pwned Passwords API. If the
|
331
|
-
<code>pwned_count</code> is higher than the optional <code>threshold</code>
|
332
|
-
then the record is marked as invalid.</p>
|
333
|
-
|
334
|
-
<p>In the case of an API error the validator will either mark the record as
|
335
|
-
valid or invalid. Alternatively it will run an associated proc or re-raise
|
336
|
-
the original error.</p>
|
337
|
-
|
338
|
-
|
339
|
-
</div>
|
340
|
-
</div>
|
341
|
-
<div class="tags">
|
342
|
-
|
343
|
-
<p class="tag_title">Since:</p>
|
344
|
-
<ul class="since">
|
345
|
-
|
346
|
-
<li>
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
<div class='inline'>
|
353
|
-
<p>1.2.0</p>
|
354
|
-
</div>
|
355
|
-
|
356
|
-
</li>
|
357
|
-
|
358
|
-
</ul>
|
359
|
-
|
360
|
-
</div><table class="source_code">
|
361
|
-
<tr>
|
362
|
-
<td>
|
363
|
-
<pre class="lines">
|
364
|
-
|
365
|
-
|
366
|
-
64
|
367
|
-
65
|
368
|
-
66
|
369
|
-
67
|
370
|
-
68
|
371
|
-
69
|
372
|
-
70
|
373
|
-
71
|
374
|
-
72
|
375
|
-
73
|
376
|
-
74
|
377
|
-
75
|
378
|
-
76
|
379
|
-
77
|
380
|
-
78
|
381
|
-
79
|
382
|
-
80
|
383
|
-
81
|
384
|
-
82</pre>
|
385
|
-
</td>
|
386
|
-
<td>
|
387
|
-
<pre class="code"><span class="info file"># File 'lib/pwned/not_pwned_validator.rb', line 64</span>
|
388
|
-
|
389
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_validate_each'>validate_each</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
390
|
-
<span class='kw'>begin</span>
|
391
|
-
<span class='id identifier rubyid_pwned_check'>pwned_check</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_request_options'>request_options</span><span class='rparen'>)</span>
|
392
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_pwned_check'>pwned_check</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span> <span class='op'>></span> <span class='id identifier rubyid_threshold'>threshold</span>
|
393
|
-
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='symbol'>:not_pwned</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='label'>count:</span> <span class='id identifier rubyid_pwned_check'>pwned_check</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
394
|
-
<span class='kw'>end</span>
|
395
|
-
<span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Error.html" title="Pwned::Error (class)">Error</a></span></span> <span class='op'>=></span> <span class='id identifier rubyid_error'>error</span>
|
396
|
-
<span class='kw'>case</span> <span class='id identifier rubyid_on_error'>on_error</span>
|
397
|
-
<span class='kw'>when</span> <span class='symbol'>:invalid</span>
|
398
|
-
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='symbol'>:pwned_error</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='label'>message:</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:error_message</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
399
|
-
<span class='kw'>when</span> <span class='symbol'>:valid</span>
|
400
|
-
<span class='comment'># Do nothing, consider the record valid
|
401
|
-
</span> <span class='kw'>when</span> <span class='const'>Proc</span>
|
402
|
-
<span class='id identifier rubyid_on_error'>on_error</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
|
403
|
-
<span class='kw'>else</span>
|
404
|
-
<span class='id identifier rubyid_raise'>raise</span>
|
405
|
-
<span class='kw'>end</span>
|
406
|
-
<span class='kw'>end</span>
|
407
|
-
<span class='kw'>end</span></pre>
|
408
|
-
</td>
|
409
|
-
</tr>
|
410
|
-
</table>
|
411
|
-
</div>
|
412
|
-
|
413
|
-
</div>
|
414
|
-
|
415
|
-
</div>
|
416
|
-
|
417
|
-
<div id="footer">
|
418
|
-
Generated on Wed Mar 14 11:06:58 2018 by
|
419
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
420
|
-
0.9.12 (ruby-2.5.0).
|
421
|
-
</div>
|
422
|
-
|
423
|
-
</div>
|
424
|
-
</body>
|
425
|
-
</html>
|
data/docs/Pwned.html
DELETED
@@ -1,513 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
Module: Pwned
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.12
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "Pwned";
|
19
|
-
relpath = '';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="_index.html">Index (P)</a> »
|
40
|
-
|
41
|
-
|
42
|
-
<span class="title">Pwned</span>
|
43
|
-
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<div id="search">
|
47
|
-
|
48
|
-
<a class="full_list_link" id="class_list_link"
|
49
|
-
href="class_list.html">
|
50
|
-
|
51
|
-
<svg width="24" height="24">
|
52
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
-
</svg>
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div id="content"><h1>Module: Pwned
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<dl>
|
80
|
-
<dt>Defined in:</dt>
|
81
|
-
<dd>lib/pwned.rb<span class="defines">,<br />
|
82
|
-
lib/pwned/error.rb,<br /> lib/pwned/version.rb,<br /> lib/pwned/password.rb</span>
|
83
|
-
</dd>
|
84
|
-
</dl>
|
85
|
-
|
86
|
-
</div>
|
87
|
-
|
88
|
-
<h2>Overview</h2><div class="docstring">
|
89
|
-
<div class="discussion">
|
90
|
-
|
91
|
-
<p>The main namespace for <code>Pwned</code>. Includes convenience methods for
|
92
|
-
getting the results for a password.</p>
|
93
|
-
|
94
|
-
|
95
|
-
</div>
|
96
|
-
</div>
|
97
|
-
<div class="tags">
|
98
|
-
|
99
|
-
|
100
|
-
</div><h2>Defined Under Namespace</h2>
|
101
|
-
<p class="children">
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Pwned/Error.html" title="Pwned::Error (class)">Error</a></span>, <span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span>, <span class='object_link'><a href="Pwned/TimeoutError.html" title="Pwned::TimeoutError (class)">TimeoutError</a></span>
|
107
|
-
|
108
|
-
|
109
|
-
</p>
|
110
|
-
|
111
|
-
<h2>Constant Summary</h2>
|
112
|
-
<dl class="constants">
|
113
|
-
|
114
|
-
<dt id="VERSION-constant" class="">VERSION =
|
115
|
-
<div class="docstring">
|
116
|
-
<div class="discussion">
|
117
|
-
|
118
|
-
<p>The current version of the <code>pwned</code> gem.</p>
|
119
|
-
|
120
|
-
|
121
|
-
</div>
|
122
|
-
</div>
|
123
|
-
<div class="tags">
|
124
|
-
|
125
|
-
|
126
|
-
</div>
|
127
|
-
</dt>
|
128
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.1.0</span><span class='tstring_end'>"</span></span></pre></dd>
|
129
|
-
|
130
|
-
</dl>
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
<h2>
|
140
|
-
Class Method Summary
|
141
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
142
|
-
</h2>
|
143
|
-
|
144
|
-
<ul class="summary">
|
145
|
-
|
146
|
-
<li class="public ">
|
147
|
-
<span class="summary_signature">
|
148
|
-
|
149
|
-
<a href="#pwned%3F-class_method" title="pwned? (class method)">.<strong>pwned?</strong>(password, request_options = {}) ⇒ Boolean </a>
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
</span>
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
<span class="summary_desc"><div class='inline'>
|
164
|
-
<p>Returns <code>true</code> when the password has been pwned.</p>
|
165
|
-
</div></span>
|
166
|
-
|
167
|
-
</li>
|
168
|
-
|
169
|
-
|
170
|
-
<li class="public ">
|
171
|
-
<span class="summary_signature">
|
172
|
-
|
173
|
-
<a href="#pwned_count-class_method" title="pwned_count (class method)">.<strong>pwned_count</strong>(password, request_options = {}) ⇒ Integer </a>
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
</span>
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
<span class="summary_desc"><div class='inline'>
|
188
|
-
<p>Returns number of times the password has been pwned.</p>
|
189
|
-
</div></span>
|
190
|
-
|
191
|
-
</li>
|
192
|
-
|
193
|
-
|
194
|
-
</ul>
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
<div id="class_method_details" class="method_details_list">
|
200
|
-
<h2>Class Method Details</h2>
|
201
|
-
|
202
|
-
|
203
|
-
<div class="method_details first">
|
204
|
-
<h3 class="signature first" id="pwned?-class_method">
|
205
|
-
|
206
|
-
.<strong>pwned?</strong>(password, request_options = {}) ⇒ <tt>Boolean</tt>
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
</h3><div class="docstring">
|
213
|
-
<div class="discussion">
|
214
|
-
|
215
|
-
<p>Returns <code>true</code> when the password has been pwned.</p>
|
216
|
-
|
217
|
-
|
218
|
-
</div>
|
219
|
-
</div>
|
220
|
-
<div class="tags">
|
221
|
-
|
222
|
-
<div class="examples">
|
223
|
-
<p class="tag_title">Examples:</p>
|
224
|
-
|
225
|
-
|
226
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Pwned (module)">Pwned</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>password</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> true
|
227
|
-
</span><span class='const'><span class='object_link'><a href="" title="Pwned (module)">Pwned</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>pwned::password</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> false</span></code></pre>
|
228
|
-
|
229
|
-
</div>
|
230
|
-
<p class="tag_title">Parameters:</p>
|
231
|
-
<ul class="param">
|
232
|
-
|
233
|
-
<li>
|
234
|
-
|
235
|
-
<span class='name'>password</span>
|
236
|
-
|
237
|
-
|
238
|
-
<span class='type'>(<tt>String</tt>)</span>
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
—
|
243
|
-
<div class='inline'>
|
244
|
-
<p>The password you want to check against the API.</p>
|
245
|
-
</div>
|
246
|
-
|
247
|
-
</li>
|
248
|
-
|
249
|
-
<li>
|
250
|
-
|
251
|
-
<span class='name'>request_options</span>
|
252
|
-
|
253
|
-
|
254
|
-
<span class='type'>(<tt>Hash</tt>)</span>
|
255
|
-
|
256
|
-
|
257
|
-
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
258
|
-
|
259
|
-
|
260
|
-
—
|
261
|
-
<div class='inline'>
|
262
|
-
<p>Options that can be passed to <code>open</code> when calling the API</p>
|
263
|
-
</div>
|
264
|
-
|
265
|
-
</li>
|
266
|
-
|
267
|
-
</ul>
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
<p class="tag_title">Options Hash (<tt>request_options</tt>):</p>
|
275
|
-
<ul class="option">
|
276
|
-
|
277
|
-
<li>
|
278
|
-
<span class="name">'User-Agent'</span>
|
279
|
-
<span class="type">(<tt>String</tt>)</span>
|
280
|
-
<span class="default">
|
281
|
-
|
282
|
-
— default:
|
283
|
-
<tt>"Ruby Pwned::Password #{Pwned::VERSION}"</tt>
|
284
|
-
|
285
|
-
</span>
|
286
|
-
|
287
|
-
— <div class='inline'>
|
288
|
-
<p>The user agent used when making an API request.</p>
|
289
|
-
</div>
|
290
|
-
|
291
|
-
</li>
|
292
|
-
|
293
|
-
</ul>
|
294
|
-
|
295
|
-
|
296
|
-
<p class="tag_title">Returns:</p>
|
297
|
-
<ul class="return">
|
298
|
-
|
299
|
-
<li>
|
300
|
-
|
301
|
-
|
302
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
—
|
307
|
-
<div class='inline'>
|
308
|
-
<p>Whether the password appears in the data breaches or not.</p>
|
309
|
-
</div>
|
310
|
-
|
311
|
-
</li>
|
312
|
-
|
313
|
-
</ul>
|
314
|
-
<p class="tag_title">Since:</p>
|
315
|
-
<ul class="since">
|
316
|
-
|
317
|
-
<li>
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
<div class='inline'>
|
324
|
-
<p>1.1.0</p>
|
325
|
-
</div>
|
326
|
-
|
327
|
-
</li>
|
328
|
-
|
329
|
-
</ul>
|
330
|
-
|
331
|
-
</div><table class="source_code">
|
332
|
-
<tr>
|
333
|
-
<td>
|
334
|
-
<pre class="lines">
|
335
|
-
|
336
|
-
|
337
|
-
38
|
338
|
-
39
|
339
|
-
40</pre>
|
340
|
-
</td>
|
341
|
-
<td>
|
342
|
-
<pre class="code"><span class="info file"># File 'lib/pwned.rb', line 38</span>
|
343
|
-
|
344
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span><span class='lparen'>(</span><span class='id identifier rubyid_password'>password</span><span class='comma'>,</span> <span class='id identifier rubyid_request_options'>request_options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
345
|
-
<span class='const'><span class='object_link'><a href="" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_password'>password</span><span class='comma'>,</span> <span class='id identifier rubyid_request_options'>request_options</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span>
|
346
|
-
<span class='kw'>end</span></pre>
|
347
|
-
</td>
|
348
|
-
</tr>
|
349
|
-
</table>
|
350
|
-
</div>
|
351
|
-
|
352
|
-
<div class="method_details ">
|
353
|
-
<h3 class="signature " id="pwned_count-class_method">
|
354
|
-
|
355
|
-
.<strong>pwned_count</strong>(password, request_options = {}) ⇒ <tt>Integer</tt>
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
</h3><div class="docstring">
|
362
|
-
<div class="discussion">
|
363
|
-
|
364
|
-
<p>Returns number of times the password has been pwned.</p>
|
365
|
-
|
366
|
-
|
367
|
-
</div>
|
368
|
-
</div>
|
369
|
-
<div class="tags">
|
370
|
-
|
371
|
-
<div class="examples">
|
372
|
-
<p class="tag_title">Examples:</p>
|
373
|
-
|
374
|
-
|
375
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Pwned (module)">Pwned</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>password</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> 3303003
|
376
|
-
</span><span class='const'><span class='object_link'><a href="" title="Pwned (module)">Pwned</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>pwned::password</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> 0</span></code></pre>
|
377
|
-
|
378
|
-
</div>
|
379
|
-
<p class="tag_title">Parameters:</p>
|
380
|
-
<ul class="param">
|
381
|
-
|
382
|
-
<li>
|
383
|
-
|
384
|
-
<span class='name'>password</span>
|
385
|
-
|
386
|
-
|
387
|
-
<span class='type'>(<tt>String</tt>)</span>
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
—
|
392
|
-
<div class='inline'>
|
393
|
-
<p>The password you want to check against the API.</p>
|
394
|
-
</div>
|
395
|
-
|
396
|
-
</li>
|
397
|
-
|
398
|
-
<li>
|
399
|
-
|
400
|
-
<span class='name'>request_options</span>
|
401
|
-
|
402
|
-
|
403
|
-
<span class='type'>(<tt>Hash</tt>)</span>
|
404
|
-
|
405
|
-
|
406
|
-
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
407
|
-
|
408
|
-
|
409
|
-
—
|
410
|
-
<div class='inline'>
|
411
|
-
<p>Options that can be passed to <code>open</code> when calling the API</p>
|
412
|
-
</div>
|
413
|
-
|
414
|
-
</li>
|
415
|
-
|
416
|
-
</ul>
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
<p class="tag_title">Options Hash (<tt>request_options</tt>):</p>
|
424
|
-
<ul class="option">
|
425
|
-
|
426
|
-
<li>
|
427
|
-
<span class="name">'User-Agent'</span>
|
428
|
-
<span class="type">(<tt>String</tt>)</span>
|
429
|
-
<span class="default">
|
430
|
-
|
431
|
-
— default:
|
432
|
-
<tt>"Ruby Pwned::Password #{Pwned::VERSION}"</tt>
|
433
|
-
|
434
|
-
</span>
|
435
|
-
|
436
|
-
— <div class='inline'>
|
437
|
-
<p>The user agent used when making an API request.</p>
|
438
|
-
</div>
|
439
|
-
|
440
|
-
</li>
|
441
|
-
|
442
|
-
</ul>
|
443
|
-
|
444
|
-
|
445
|
-
<p class="tag_title">Returns:</p>
|
446
|
-
<ul class="return">
|
447
|
-
|
448
|
-
<li>
|
449
|
-
|
450
|
-
|
451
|
-
<span class='type'>(<tt>Integer</tt>)</span>
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
—
|
456
|
-
<div class='inline'>
|
457
|
-
<p>The number of times the password has appeared in the data breaches.</p>
|
458
|
-
</div>
|
459
|
-
|
460
|
-
</li>
|
461
|
-
|
462
|
-
</ul>
|
463
|
-
<p class="tag_title">Since:</p>
|
464
|
-
<ul class="since">
|
465
|
-
|
466
|
-
<li>
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
<div class='inline'>
|
473
|
-
<p>1.1.0</p>
|
474
|
-
</div>
|
475
|
-
|
476
|
-
</li>
|
477
|
-
|
478
|
-
</ul>
|
479
|
-
|
480
|
-
</div><table class="source_code">
|
481
|
-
<tr>
|
482
|
-
<td>
|
483
|
-
<pre class="lines">
|
484
|
-
|
485
|
-
|
486
|
-
57
|
487
|
-
58
|
488
|
-
59</pre>
|
489
|
-
</td>
|
490
|
-
<td>
|
491
|
-
<pre class="code"><span class="info file"># File 'lib/pwned.rb', line 57</span>
|
492
|
-
|
493
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span><span class='lparen'>(</span><span class='id identifier rubyid_password'>password</span><span class='comma'>,</span> <span class='id identifier rubyid_request_options'>request_options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
494
|
-
<span class='const'><span class='object_link'><a href="" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_password'>password</span><span class='comma'>,</span> <span class='id identifier rubyid_request_options'>request_options</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span>
|
495
|
-
<span class='kw'>end</span></pre>
|
496
|
-
</td>
|
497
|
-
</tr>
|
498
|
-
</table>
|
499
|
-
</div>
|
500
|
-
|
501
|
-
</div>
|
502
|
-
|
503
|
-
</div>
|
504
|
-
|
505
|
-
<div id="footer">
|
506
|
-
Generated on Wed Mar 14 11:06:58 2018 by
|
507
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
508
|
-
0.9.12 (ruby-2.5.0).
|
509
|
-
</div>
|
510
|
-
|
511
|
-
</div>
|
512
|
-
</body>
|
513
|
-
</html>
|