pwned 2.1.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/tests.yml +45 -0
- data/CHANGELOG.md +23 -1
- data/README.md +138 -31
- data/lib/pwned/deep_merge.rb +13 -0
- data/lib/pwned/hashed_password.rb +11 -3
- data/lib/pwned/password.rb +10 -4
- data/lib/pwned/password_base.rb +12 -3
- data/lib/pwned/version.rb +1 -1
- data/lib/pwned.rb +29 -0
- metadata +9 -7
- data/.travis.yml +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f655789ebeb4d8fc8cdd1a105960358b8995ecb2d65d50542c124dd025add187
|
4
|
+
data.tar.gz: 32b7024253941258a9d93e3fd556c25d7dc5f1d91b55c414d547bce7cd81f042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f298ab9734b71e795cb014986b93c37642539c45225add31f55a105a4238b0dcd57ae298682df0ad2ed69203d42f13181715dbcfeb1fe8f188a497e51f82cab9
|
7
|
+
data.tar.gz: c494a1fd491608e0bee4d47a97b356ae22887b2a041e33348a8784c14fbe68d5ab78451eb2b2e255e0b2f1702d41424b5a2e0b83549a93a3a9a2dd86abd1ad39
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: philnash
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [2.6, 2.7, 3.0, 3.1, head]
|
12
|
+
rails: [4.2.11.3, 5.0.7.2, 5.1.7, 5.2.4.4, 6.0.3.4, 6.1.0]
|
13
|
+
exclude:
|
14
|
+
# Ruby 3.0 and Rails 5 do not get along together.
|
15
|
+
- ruby: 3.0
|
16
|
+
rails: 5.0.7.2
|
17
|
+
- ruby: 3.0
|
18
|
+
rails: 5.1.7
|
19
|
+
- ruby: 3.0
|
20
|
+
rails: 5.2.4.4
|
21
|
+
- ruby: 3.1
|
22
|
+
rails: 5.0.7.2
|
23
|
+
- ruby: 3.1
|
24
|
+
rails: 5.1.7
|
25
|
+
- ruby: 3.1
|
26
|
+
rails: 5.2.4.4
|
27
|
+
- ruby: head
|
28
|
+
rails: 5.0.7.2
|
29
|
+
- ruby: head
|
30
|
+
rails: 5.1.7
|
31
|
+
- ruby: head
|
32
|
+
rails: 5.2.4.4
|
33
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
34
|
+
env:
|
35
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
36
|
+
steps:
|
37
|
+
- uses: actions/checkout@v2
|
38
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
- name: "Install dependencies (rails: ${{matrix.rails}})"
|
43
|
+
run: bundle install
|
44
|
+
- name: Run tests
|
45
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
# Changelog for `Pwned`
|
2
2
|
|
3
|
-
## Ongoing [☰](https://github.com/philnash/pwned/compare/v2.0
|
3
|
+
## Ongoing [☰](https://github.com/philnash/pwned/compare/v2.4.0...master)
|
4
|
+
|
5
|
+
## 2.4.0 (February 23, 2022) [☰](https://github.com/philnash/pwned/compare/v2.3.0...v2.4.0)
|
6
|
+
|
7
|
+
- Minor updates
|
8
|
+
|
9
|
+
- Adds `default_request_options` to set global defaults for the gem
|
10
|
+
- Adds Ruby 3.1 to the test matrix
|
11
|
+
|
12
|
+
## 2.3.0 (August 30, 2021) [☰](https://github.com/philnash/pwned/compare/v2.2.0...v2.3.0)
|
13
|
+
|
14
|
+
- Minor updates
|
15
|
+
|
16
|
+
- Restores `Net::HTTP` default behaviour to use environment supplied HTTP
|
17
|
+
proxy
|
18
|
+
- Adds `ignore_env_proxy` to ignore any proxies set in the environment
|
19
|
+
|
20
|
+
## 2.2.0 (March 27, 2021) [☰](https://github.com/philnash/pwned/compare/v2.1.0...v2.2.0)
|
21
|
+
|
22
|
+
- Minor updates
|
23
|
+
|
24
|
+
- Adds `:proxy` option to `request_options` to directly set a proxy on the
|
25
|
+
request. Fixes #21, thanks [dparpyani](https://github.com/dparpyani).
|
4
26
|
|
5
27
|
## 2.1.0 (July 8, 2020) [☰](https://github.com/philnash/pwned/compare/v2.0.2...v2.1.0)
|
6
28
|
|
data/README.md
CHANGED
@@ -2,32 +2,37 @@
|
|
2
2
|
|
3
3
|
An easy, Ruby way to use the Pwned Passwords API.
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/pwned.svg)](https://rubygems.org/gems/pwned)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/pwned.svg)](https://rubygems.org/gems/pwned) ![Build Status](https://github.com/philnash/pwned/workflows/tests/badge.svg) [![Maintainability](https://codeclimate.com/github/philnash/pwned/badges/gpa.svg)](https://codeclimate.com/github/philnash/pwned/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/pwned.svg?branch=master)](https://inch-ci.org/github/philnash/pwned)
|
6
6
|
|
7
7
|
[API docs](https://www.rubydoc.info/gems/pwned) | [GitHub repo](https://github.com/philnash/pwned)
|
8
8
|
|
9
9
|
## Table of Contents
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
11
|
+
* [Table of Contents](#table-of-contents)
|
12
|
+
* [About](#about)
|
13
|
+
* [Installation](#installation)
|
14
|
+
* [Usage](#usage)
|
15
|
+
* [Plain Ruby](#plain-ruby)
|
16
|
+
* [Custom request options](#custom-request-options)
|
17
|
+
* [HTTP Headers](#http-headers)
|
18
|
+
* [HTTP Proxy](#http-proxy)
|
19
|
+
* [ActiveRecord Validator](#activerecord-validator)
|
20
|
+
* [I18n](#i18n)
|
21
|
+
* [Threshold](#threshold)
|
22
|
+
* [Network Error Handling](#network-error-handling)
|
23
|
+
* [Custom Request Options](#custom-request-options-1)
|
24
|
+
* [HTTP Headers](#http-headers-1)
|
25
|
+
* [HTTP Proxy](#http-proxy-1)
|
26
|
+
* [Using Asynchronously](#using-asynchronously)
|
27
|
+
* [Devise](#devise)
|
28
|
+
* [Rodauth](#rodauth)
|
29
|
+
* [Command line](#command-line)
|
30
|
+
* [Unpwn](#unpwn)
|
31
|
+
* [How Pwned is Pi?](#how-pwned-is-pi)
|
32
|
+
* [Development](#development)
|
33
|
+
* [Contributing](#contributing)
|
34
|
+
* [License](#license)
|
35
|
+
* [Code of Conduct](#code-of-conduct)
|
31
36
|
|
32
37
|
## About
|
33
38
|
|
@@ -103,13 +108,57 @@ Pwned.pwned_count("password")
|
|
103
108
|
#=> 3303003
|
104
109
|
```
|
105
110
|
|
106
|
-
####
|
111
|
+
#### Custom request options
|
107
112
|
|
108
|
-
You can set
|
109
|
-
|
113
|
+
You can set HTTP request options to be used with `Net::HTTP.start` when making the request to the API. These options are documented in the [`Net::HTTP.start` documentation](https://ruby-doc.org/stdlib-3.0.0/libdoc/net/http/rdoc/Net/HTTP.html#method-c-start).
|
114
|
+
|
115
|
+
You can pass the options to the constructor:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
password = Pwned::Password.new("password", read_timeout: 10)
|
119
|
+
```
|
120
|
+
|
121
|
+
You can also specify global defaults:
|
110
122
|
|
111
123
|
```ruby
|
112
|
-
|
124
|
+
Pwned.default_request_options = { read_timeout: 10 }
|
125
|
+
```
|
126
|
+
|
127
|
+
##### HTTP Headers
|
128
|
+
|
129
|
+
The `:headers` option defines defines HTTP headers. These headers must be string keys.
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
password = Pwned::Password.new("password", headers: {
|
133
|
+
'User-Agent' => 'Super fun new user agent'
|
134
|
+
})
|
135
|
+
```
|
136
|
+
|
137
|
+
##### HTTP Proxy
|
138
|
+
|
139
|
+
An HTTP proxy can be set using the `http_proxy` or `HTTP_PROXY` environment variable. This is the same way that `Net::HTTP` handles HTTP proxies if no proxy options are given. See [`URI::Generic#find_proxy`](https://ruby-doc.org/stdlib-3.0.1/libdoc/uri/rdoc/URI/Generic.html#method-i-find_proxy) for full details on how Ruby detects a proxy from the environment.
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
# Set in the environment
|
143
|
+
ENV["http_proxy"] = "https://username:password@example.com:12345"
|
144
|
+
|
145
|
+
# Will use the above proxy
|
146
|
+
password = Pwned::Password.new("password")
|
147
|
+
```
|
148
|
+
|
149
|
+
You can specify a custom HTTP proxy with the `:proxy` option:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
password = Pwned::Password.new(
|
153
|
+
"password",
|
154
|
+
proxy: "https://username:password@example.com:12345"
|
155
|
+
)
|
156
|
+
```
|
157
|
+
|
158
|
+
If you don't want to set a proxy and you don't want a proxy to be inferred from the environment, set the `:ignore_env_proxy` key:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
password = Pwned::Password.new("password", ignore_env_proxy: true)
|
113
162
|
```
|
114
163
|
|
115
164
|
### ActiveRecord Validator
|
@@ -180,28 +229,82 @@ end
|
|
180
229
|
#### Custom Request Options
|
181
230
|
|
182
231
|
You can configure network requests made from the validator using `:request_options` (see [Net::HTTP.start](http://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html#method-c-start) for the list of available options).
|
183
|
-
In addition to these options, HTTP headers can be specified with the `:headers` key, e.g. `"User-Agent"`):
|
184
232
|
|
185
233
|
```ruby
|
186
234
|
validates :password, not_pwned: {
|
187
|
-
request_options: {
|
235
|
+
request_options: {
|
236
|
+
read_timeout: 5,
|
237
|
+
open_timeout: 1
|
238
|
+
}
|
239
|
+
}
|
240
|
+
```
|
241
|
+
|
242
|
+
These options override the globally defined default options (see above).
|
243
|
+
|
244
|
+
In addition to these options, you can also set the following:
|
245
|
+
|
246
|
+
##### HTTP Headers
|
247
|
+
|
248
|
+
HTTP headers can be specified with the `:headers` key (e.g. `"User-Agent"`)
|
249
|
+
|
250
|
+
```ruby
|
251
|
+
validates :password, not_pwned: {
|
252
|
+
request_options: {
|
253
|
+
headers: { "User-Agent" => "Super fun user agent" }
|
254
|
+
}
|
255
|
+
}
|
256
|
+
```
|
257
|
+
|
258
|
+
##### HTTP Proxy
|
259
|
+
|
260
|
+
An HTTP proxy can be set using the `http_proxy` or `HTTP_PROXY` environment variable. This is the same way that `Net::HTTP` handles HTTP proxies if no proxy options are given. See [`URI::Generic#find_proxy`](https://ruby-doc.org/stdlib-3.0.1/libdoc/uri/rdoc/URI/Generic.html#method-i-find_proxy) for full details on how Ruby detects a proxy from the environment.
|
261
|
+
|
262
|
+
```ruby
|
263
|
+
# Set in the environment
|
264
|
+
ENV["http_proxy"] = "https://username:password@example.com:12345"
|
265
|
+
|
266
|
+
validates :password, not_pwned: true
|
267
|
+
```
|
268
|
+
|
269
|
+
You can specify a custom HTTP proxy with the `:proxy` key:
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
validates :password, not_pwned: {
|
273
|
+
request_options: {
|
274
|
+
proxy: "https://username:password@example.com:12345"
|
275
|
+
}
|
276
|
+
}
|
277
|
+
```
|
278
|
+
|
279
|
+
If you don't want to set a proxy and you don't want a proxy to be inferred from the environment, set the `:ignore_env_proxy` key:
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
validates :password, not_pwned: {
|
283
|
+
request_options: {
|
284
|
+
ignore_env_proxy: true
|
285
|
+
}
|
188
286
|
}
|
189
287
|
```
|
190
288
|
|
191
289
|
### Using Asynchronously
|
192
290
|
|
193
|
-
You may have a use case for hashing the password in advance, and then making the call to the Pwned
|
194
|
-
(for example if you want to enqueue a job without storing the plaintext password):
|
291
|
+
You may have a use case for hashing the password in advance, and then making the call to the Pwned Passwords API later (for example if you want to enqueue a job without storing the plaintext password). To do this, you can hash the password with the `Pwned.hash_password` method and then initialize the `Pwned::HashedPassword` class with the hash, like this:
|
195
292
|
|
196
293
|
```ruby
|
197
294
|
hashed_password = Pwned.hash_password(password)
|
198
295
|
# some time later
|
199
|
-
Pwned::
|
296
|
+
Pwned::HashedPassword.new(hashed_password, request_options).pwned?
|
200
297
|
```
|
201
298
|
|
299
|
+
The `Pwned::HashedPassword` constructor takes all the same options as the regular `Pwned::Password` contructor.
|
300
|
+
|
202
301
|
### Devise
|
203
302
|
|
204
|
-
If you are using Devise I recommend you use the [devise-pwned_password extension](https://github.com/michaelbanfield/devise-pwned_password) which is now powered by this gem.
|
303
|
+
If you are using [Devise](https://github.com/heartcombo/devise) I recommend you use the [devise-pwned_password extension](https://github.com/michaelbanfield/devise-pwned_password) which is now powered by this gem.
|
304
|
+
|
305
|
+
### Rodauth
|
306
|
+
|
307
|
+
If you are using [Rodauth](https://github.com/jeremyevans/rodauth) then you can use the [rodauth-pwned](https://github.com/janko/rodauth-pwned) feature which is powered by this gem.
|
205
308
|
|
206
309
|
### Command line
|
207
310
|
|
@@ -221,6 +324,10 @@ $ pwned --secret
|
|
221
324
|
|
222
325
|
You will be prompted for the password, but it won't be displayed.
|
223
326
|
|
327
|
+
### Unpwn
|
328
|
+
|
329
|
+
To cut down on unnecessary network requests, [the unpwn project](https://github.com/indirect/unpwn) uses a list of the top one million passwords to check passwords against. Only if a password is not included in the top million is it then checked against the Pwned Passwords API.
|
330
|
+
|
224
331
|
## How Pwned is Pi?
|
225
332
|
|
226
333
|
[@daz](https://github.com/daz) [shared](https://twitter.com/dazonic/status/1074647842046660609) a fantastic example of using this gem to show how many times the digits of Pi have been used as passwords and leaked.
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "pwned/password_base"
|
4
|
+
require "pwned/deep_merge"
|
5
|
+
|
4
6
|
|
5
7
|
module Pwned
|
6
8
|
##
|
@@ -9,6 +11,7 @@ module Pwned
|
|
9
11
|
# @see https://haveibeenpwned.com/API/v2#PwnedPasswords
|
10
12
|
class HashedPassword
|
11
13
|
include PasswordBase
|
14
|
+
using DeepMerge
|
12
15
|
##
|
13
16
|
# Creates a new hashed password object.
|
14
17
|
#
|
@@ -19,17 +22,22 @@ module Pwned
|
|
19
22
|
#
|
20
23
|
# @param hashed_password [String] The hash of the password you want to check against the API.
|
21
24
|
# @param [Hash] request_options Options that can be passed to +Net::HTTP.start+ when
|
22
|
-
# calling the API
|
25
|
+
# calling the API. This overrides any keys specified in +Pwned.default_request_options+.
|
23
26
|
# @option request_options [Symbol] :headers ({ "User-Agent" => "Ruby Pwned::Password #{Pwned::VERSION}" })
|
24
27
|
# HTTP headers to include in the request
|
28
|
+
# @option request_options [Symbol] :ignore_env_proxy (false) The library
|
29
|
+
# will try to infer an HTTP proxy from the `http_proxy` environment
|
30
|
+
# variable. If you do not want this behaviour, set this option to true.
|
25
31
|
# @raise [TypeError] if the password is not a string.
|
26
32
|
# @since 2.1.0
|
27
33
|
def initialize(hashed_password, request_options={})
|
28
34
|
raise TypeError, "hashed_password must be of type String" unless hashed_password.is_a? String
|
29
35
|
@hashed_password = hashed_password.upcase
|
30
|
-
@request_options =
|
31
|
-
@request_headers = Hash(request_options.delete(:headers))
|
36
|
+
@request_options = Pwned.default_request_options.deep_merge(request_options)
|
37
|
+
@request_headers = Hash(@request_options.delete(:headers))
|
32
38
|
@request_headers = DEFAULT_REQUEST_HEADERS.merge(@request_headers)
|
39
|
+
@request_proxy = URI(@request_options.delete(:proxy)) if @request_options.key?(:proxy)
|
40
|
+
@ignore_env_proxy = @request_options.delete(:ignore_env_proxy) || false
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
data/lib/pwned/password.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "pwned/password_base"
|
4
|
+
require "pwned/deep_merge"
|
4
5
|
|
5
6
|
module Pwned
|
6
7
|
##
|
@@ -9,6 +10,7 @@ module Pwned
|
|
9
10
|
# @see https://haveibeenpwned.com/API/v2#PwnedPasswords
|
10
11
|
class Password
|
11
12
|
include PasswordBase
|
13
|
+
using DeepMerge
|
12
14
|
##
|
13
15
|
# @return [String] the password that is being checked.
|
14
16
|
# @since 1.0.0
|
@@ -24,19 +26,23 @@ module Pwned
|
|
24
26
|
#
|
25
27
|
# @param password [String] The password you want to check against the API.
|
26
28
|
# @param [Hash] request_options Options that can be passed to +Net::HTTP.start+ when
|
27
|
-
# calling the API
|
29
|
+
# calling the API. This overrides any keys specified in +Pwned.default_request_options+.
|
28
30
|
# @option request_options [Symbol] :headers ({ "User-Agent" => "Ruby Pwned::Password #{Pwned::VERSION}" })
|
29
31
|
# HTTP headers to include in the request
|
30
|
-
# @
|
32
|
+
# @option request_options [Symbol] :ignore_env_proxy (false) The library
|
33
|
+
# will try to infer an HTTP proxy from the `http_proxy` environment
|
34
|
+
# variable. If you do not want this behaviour, set this option to true.
|
31
35
|
# @raise [TypeError] if the password is not a string.
|
32
36
|
# @since 1.1.0
|
33
37
|
def initialize(password, request_options={})
|
34
38
|
raise TypeError, "password must be of type String" unless password.is_a? String
|
35
39
|
@password = password
|
36
40
|
@hashed_password = Pwned.hash_password(password)
|
37
|
-
@request_options =
|
38
|
-
@request_headers = Hash(request_options.delete(:headers))
|
41
|
+
@request_options = Pwned.default_request_options.deep_merge(request_options)
|
42
|
+
@request_headers = Hash(@request_options.delete(:headers))
|
39
43
|
@request_headers = DEFAULT_REQUEST_HEADERS.merge(@request_headers)
|
44
|
+
@request_proxy = URI(@request_options.delete(:proxy)) if @request_options.key?(:proxy)
|
45
|
+
@ignore_env_proxy = @request_options.delete(:ignore_env_proxy) || false
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
data/lib/pwned/password_base.rb
CHANGED
@@ -65,7 +65,7 @@ module Pwned
|
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
|
-
attr_reader :request_options, :request_headers
|
68
|
+
attr_reader :request_options, :request_headers, :request_proxy, :ignore_env_proxy
|
69
69
|
|
70
70
|
def fetch_pwned_count
|
71
71
|
for_each_response_line do |line|
|
@@ -108,7 +108,17 @@ module Pwned
|
|
108
108
|
request.initialize_http_header(request_headers)
|
109
109
|
request_options[:use_ssl] = true
|
110
110
|
|
111
|
-
|
111
|
+
environment_proxy = ignore_env_proxy ? nil : :ENV
|
112
|
+
|
113
|
+
Net::HTTP.start(
|
114
|
+
uri.host,
|
115
|
+
uri.port,
|
116
|
+
request_proxy&.host || environment_proxy,
|
117
|
+
request_proxy&.port,
|
118
|
+
request_proxy&.user,
|
119
|
+
request_proxy&.password,
|
120
|
+
request_options
|
121
|
+
) do |http|
|
112
122
|
http.request(request, &block)
|
113
123
|
end
|
114
124
|
end
|
@@ -128,6 +138,5 @@ module Pwned
|
|
128
138
|
|
129
139
|
yield last_line unless last_line.empty?
|
130
140
|
end
|
131
|
-
|
132
141
|
end
|
133
142
|
end
|
data/lib/pwned/version.rb
CHANGED
data/lib/pwned.rb
CHANGED
@@ -23,6 +23,29 @@ end
|
|
23
23
|
# results for a password.
|
24
24
|
|
25
25
|
module Pwned
|
26
|
+
@default_request_options = {}
|
27
|
+
|
28
|
+
##
|
29
|
+
# The default request options passed to +Net::HTTP.start+ when calling the API.
|
30
|
+
#
|
31
|
+
# @return [Hash]
|
32
|
+
# @see Pwned::Password#initialize
|
33
|
+
def self.default_request_options
|
34
|
+
@default_request_options
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Sets the default request options passed to +Net::HTTP.start+ when calling
|
39
|
+
# the API.
|
40
|
+
#
|
41
|
+
# The default options may be overridden in +Pwned::Password#new+.
|
42
|
+
#
|
43
|
+
# @param [Hash] request_options
|
44
|
+
# @see Pwned::Password#initialize
|
45
|
+
def self.default_request_options=(request_options)
|
46
|
+
@default_request_options = request_options
|
47
|
+
end
|
48
|
+
|
26
49
|
##
|
27
50
|
# Returns +true+ when the password has been pwned.
|
28
51
|
#
|
@@ -35,6 +58,9 @@ module Pwned
|
|
35
58
|
# calling the API
|
36
59
|
# @option request_options [Symbol] :headers ({ "User-Agent" => "Ruby Pwned::Password #{Pwned::VERSION}" })
|
37
60
|
# HTTP headers to include in the request
|
61
|
+
# @option request_options [Symbol] :ignore_env_proxy (false) The library
|
62
|
+
# will try to infer an HTTP proxy from the `http_proxy` environment
|
63
|
+
# variable. If you do not want this behaviour, set this option to true.
|
38
64
|
# @return [Boolean] Whether the password appears in the data breaches or not.
|
39
65
|
# @since 1.1.0
|
40
66
|
def self.pwned?(password, request_options={})
|
@@ -53,6 +79,9 @@ module Pwned
|
|
53
79
|
# calling the API
|
54
80
|
# @option request_options [Symbol] :headers ({ "User-Agent" => "Ruby Pwned::Password #{Pwned::VERSION}" })
|
55
81
|
# HTTP headers to include in the request
|
82
|
+
# @option request_options [Symbol] :ignore_env_proxy (false) The library
|
83
|
+
# will try to infer an HTTP proxy from the `http_proxy` environment
|
84
|
+
# variable. If you do not want this behaviour, set this option to true.
|
56
85
|
# @return [Integer] The number of times the password has appeared in the data
|
57
86
|
# breaches.
|
58
87
|
# @since 1.1.0
|
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: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,9 +94,10 @@ executables:
|
|
94
94
|
extensions: []
|
95
95
|
extra_rdoc_files: []
|
96
96
|
files:
|
97
|
+
- ".github/FUNDING.yml"
|
98
|
+
- ".github/workflows/tests.yml"
|
97
99
|
- ".gitignore"
|
98
100
|
- ".rspec"
|
99
|
-
- ".travis.yml"
|
100
101
|
- ".yardopts"
|
101
102
|
- CHANGELOG.md
|
102
103
|
- CODE_OF_CONDUCT.md
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- bin/setup
|
110
111
|
- lib/locale/en.yml
|
111
112
|
- lib/pwned.rb
|
113
|
+
- lib/pwned/deep_merge.rb
|
112
114
|
- lib/pwned/error.rb
|
113
115
|
- lib/pwned/hashed_password.rb
|
114
116
|
- lib/pwned/not_pwned_validator.rb
|
@@ -125,7 +127,7 @@ metadata:
|
|
125
127
|
documentation_uri: https://www.rubydoc.info/gems/pwned
|
126
128
|
homepage_uri: https://github.com/philnash/pwned
|
127
129
|
source_code_uri: https://github.com/philnash/pwned
|
128
|
-
post_install_message:
|
130
|
+
post_install_message:
|
129
131
|
rdoc_options: []
|
130
132
|
require_paths:
|
131
133
|
- lib
|
@@ -140,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
142
|
- !ruby/object:Gem::Version
|
141
143
|
version: '0'
|
142
144
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
145
|
+
rubygems_version: 3.1.2
|
146
|
+
signing_key:
|
145
147
|
specification_version: 4
|
146
148
|
summary: Tools to use the Pwned Passwords API.
|
147
149
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
|
4
|
-
env:
|
5
|
-
matrix:
|
6
|
-
- RAILS_VERSION=4.2.11.1
|
7
|
-
- RAILS_VERSION=5.0.7.2
|
8
|
-
- RAILS_VERSION=5.1.7
|
9
|
-
- RAILS_VERSION=5.2.3
|
10
|
-
- RAILS_VERSION=6.0.0
|
11
|
-
|
12
|
-
rvm:
|
13
|
-
- 2.7
|
14
|
-
- 2.6
|
15
|
-
- 2.5
|
16
|
-
- 2.4
|
17
|
-
- jruby
|
18
|
-
- ruby-head
|
19
|
-
|
20
|
-
before_install: gem install bundler
|
21
|
-
|
22
|
-
matrix:
|
23
|
-
allow_failures:
|
24
|
-
- rvm: ruby-head
|
25
|
-
exclude:
|
26
|
-
- rvm: 2.4
|
27
|
-
env: RAILS_VERSION=6.0.0
|