devise-two-factor 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise-two-factor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +3 -3
- data/CHANGELOG.md +15 -0
- data/README.md +75 -28
- data/SECURITY.md +5 -0
- data/UPGRADING.md +12 -3
- data/devise-two-factor.gemspec +4 -6
- data/gemfiles/rails_7.0.gemfile +2 -2
- data/gemfiles/{rails_4.1.gemfile → rails_7.1.gemfile} +2 -2
- data/lib/devise-two-factor.rb +1 -1
- data/lib/devise_two_factor/models/two_factor_backupable.rb +1 -1
- data/lib/devise_two_factor/spec_helpers/two_factor_authenticatable_shared_examples.rb +1 -1
- data/lib/devise_two_factor/spec_helpers/two_factor_backupable_shared_examples.rb +1 -1
- data/lib/devise_two_factor/strategies/two_factor_authenticatable.rb +1 -1
- data/lib/devise_two_factor/version.rb +1 -1
- data/spec/devise/models/two_factor_authenticatable_spec.rb +4 -0
- data/spec/spec_helper.rb +0 -1
- data.tar.gz.sig +0 -0
- metadata +14 -31
- metadata.gz.sig +0 -0
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_5.1.gemfile +0 -8
- data/gemfiles/rails_5.2.gemfile +0 -8
- data/gemfiles/rails_6.0.gemfile +0 -8
- data/gemfiles/rails_6.1.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c55843526e6b06f1804f07a6c38bd6a247006d90ba43a5f6659cb8c0f98d53ff
|
4
|
+
data.tar.gz: e0e67eab0624fa0fa88f9719afbbc1da169bcf280f60d249efd96bc98ad10629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc10ef88ba898b09fd310dc3015853027b8120915d35c2c491dad9976d5809981486efc4d49e4d44abdbf01573ca643de31029a279bffc43609b92e8101cf0eb
|
7
|
+
data.tar.gz: 2dd29e26cc88edcea8044f6acf22d55275550d9d5c02cbc07337f1509b7b61de766b9e2ab6f1cc436ee569c016fea51130b4bff42853088807c576e2c363f9d0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,14 +12,14 @@ jobs:
|
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
14
|
# Due to https://github.com/actions/runner/issues/849, we should quote versions
|
15
|
-
ruby: ['
|
16
|
-
rails: ['7.0']
|
15
|
+
ruby: ['3.1', '3.2', '3.3', 'truffleruby-head']
|
16
|
+
rails: ['7.0', '7.1']
|
17
17
|
|
18
18
|
name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
|
19
19
|
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
20
20
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile
|
21
21
|
steps:
|
22
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v4
|
23
23
|
- name: Set up Ruby
|
24
24
|
uses: ruby/setup-ruby@v1
|
25
25
|
with:
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 5.1.0
|
6
|
+
|
7
|
+
- Remove faker dev dependency
|
8
|
+
- Insert two_factor_authenticatable at the top of the devise module list
|
9
|
+
- README and CI improvements
|
10
|
+
|
11
|
+
## 5.0.0
|
12
|
+
|
13
|
+
**Breaking Changes**
|
14
|
+
- attr_encrypted has been deprecated in favor of native Rails attribute encryption. See [UPGRADING.md](UPGRADING.md) for details on how to migrate your records. You **must** use or build a migration strategy (see examples in [UPGRADING.md](UPGRADING.md)) to use existing data!
|
15
|
+
- Rails 7 is now required.
|
16
|
+
|
17
|
+
## 4.1.0 / 4.1.1
|
18
|
+
- Add support for attr_encrypted v4
|
19
|
+
|
5
20
|
## 4.0.2
|
6
21
|
- Add Rails 7.0 support
|
7
22
|
- Renew signing certificate
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Devise-Two-Factor Authentication
|
2
|
-
By [Tinfoil Security](https://www.tinfoilsecurity.com/) (acq. [Synopsys](https://www.synopsys.com/) 2020). Interested in [working with us](https://www.synopsys.com/careers.html)? We're hiring!
|
3
2
|
|
4
|
-
![Build Status](https://github.com/
|
3
|
+
![Build Status](https://github.com/devise-two-factor/devise-two-factor/actions/workflows/ci.yml/badge.svg)
|
5
4
|
|
6
5
|
Devise-Two-Factor is a minimalist extension to Devise which offers support for two-factor authentication, through the [TOTP](https://en.wikipedia.org/wiki/Time-based_One-Time_Password) scheme. It:
|
7
6
|
|
@@ -11,9 +10,11 @@ Devise-Two-Factor is a minimalist extension to Devise which offers support for t
|
|
11
10
|
* Is extensible, and includes two-factor backup codes as an example of how plugins can be structured
|
12
11
|
|
13
12
|
## Contributing
|
13
|
+
|
14
14
|
We welcome pull requests, bug reports, and other contributions. We're especially looking for help getting this gem fully compatible with Rails 5+ and squashing any deprecation messages.
|
15
15
|
|
16
16
|
## Example App
|
17
|
+
|
17
18
|
An example Rails 4 application is provided in the `demo` directory. It showcases a minimal example of Devise-Two-Factor in action, and can act as a reference for integrating the gem into your own application.
|
18
19
|
|
19
20
|
For the demo app to work, create an encryption key and store it as an environment variable. One way to do this is to create a file named `local_env.yml` in the application root. Set the value of `ENCRYPTION_KEY` in the YML file. That value will be loaded into the application environment by `application.rb`.
|
@@ -27,15 +28,31 @@ Devise-Two-Factor doesn't require much to get started, but there are two prerequ
|
|
27
28
|
|
28
29
|
First, you'll need a Rails application setup with Devise. Visit the Devise [homepage](https://github.com/plataformatec/devise) for instructions.
|
29
30
|
|
30
|
-
Devise-Two-Factor uses [ActiveRecord encrypted attributes](https://edgeguides.rubyonrails.org/active_record_encryption.html)
|
31
|
+
Devise-Two-Factor uses [ActiveRecord encrypted attributes](https://edgeguides.rubyonrails.org/active_record_encryption.html). If you haven't already set up ActiveRecord encryption you must generate a key set and configure your application to use them either with Rails' encrypted credentials or from another source such as environment variables.
|
31
32
|
|
32
33
|
```bash
|
33
|
-
#
|
34
|
-
|
34
|
+
# Generates a random key set and outputs it to stdout
|
35
|
+
./bin/rails db:encryption:init
|
36
|
+
```
|
37
|
+
|
38
|
+
You can load the key set using Rails' credentials.
|
39
|
+
|
40
|
+
```bash
|
41
|
+
# Copy the generated key set into your encrypted credentials file
|
42
|
+
# Setting the EDITOR environment variable is optional, but without it your default editor will open
|
43
|
+
EDITOR="code --wait" ./bin/rails credentials:edit
|
44
|
+
```
|
35
45
|
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
To learn more about credentials run `./bin/rails credentials:help`.
|
47
|
+
|
48
|
+
Alternatively, you can configure your application with environment variables rather than Rails' credentials.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
# Copy the generate key set and set them as environment variables
|
52
|
+
|
53
|
+
config.active_record.encryption.primary_key = ENV['ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY']
|
54
|
+
config.active_record.encryption.deterministic_key = ENV['ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY']
|
55
|
+
config.active_record.encryption.key_derivation_salt = ENV['ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT']
|
39
56
|
```
|
40
57
|
|
41
58
|
Add Devise-Two-Factor to your Gemfile with:
|
@@ -58,11 +75,13 @@ Where `MODEL` is the name of the model you wish to add two-factor functionality
|
|
58
75
|
This generator will:
|
59
76
|
|
60
77
|
1. Create a new migration which adds a few columns to the specified model:
|
78
|
+
|
61
79
|
```ruby
|
62
80
|
add_column :users, :otp_secret, :string
|
63
81
|
add_column :users, :consumed_timestep, :integer
|
64
82
|
add_column :users, :otp_required_for_login, :boolean
|
65
83
|
```
|
84
|
+
|
66
85
|
1. Edit `app/models/MODEL.rb` (where MODEL is your model name):
|
67
86
|
* add the `:two_factor_authenticatable` devise module
|
68
87
|
* remove the `:database_authenticatable` if present because it is incompatible with `:two_factor_authenticatable`
|
@@ -95,6 +114,7 @@ Finally you should verify that `:database_authenticatable` is **not** being load
|
|
95
114
|
**Loading both `:database_authenticatable` and `:two_factor_authenticatable` in a model is a security issue** It will allow users to bypass two-factor authenticatable due to the way Warden handles cascading strategies!
|
96
115
|
|
97
116
|
## Designing Your Workflow
|
117
|
+
|
98
118
|
Devise-Two-Factor only worries about the backend, leaving the details of the integration up to you. This means that you're responsible for building the UI that drives the gem. While there is an example Rails application included in the gem, it is important to remember that this gem is intentionally very open-ended, and you should build a user experience which fits your individual application.
|
99
119
|
|
100
120
|
There are two key workflows you'll have to think about:
|
@@ -104,8 +124,8 @@ There are two key workflows you'll have to think about:
|
|
104
124
|
|
105
125
|
We chose to keep things as simple as possible, and our implementation can be found by registering at [Tinfoil Security](https://www.tinfoilsecurity.com/), and enabling two-factor authentication from the [security settings page](https://www.tinfoilsecurity.com/account/security).
|
106
126
|
|
107
|
-
|
108
127
|
### Logging In
|
128
|
+
|
109
129
|
Logging in with two-factor authentication works extremely similarly to regular database authentication in Devise. The `TwoFactorAuthenticatable` strategy accepts three parameters:
|
110
130
|
|
111
131
|
1. email
|
@@ -115,11 +135,13 @@ Logging in with two-factor authentication works extremely similarly to regular d
|
|
115
135
|
These parameters can be submitted to the standard Devise login route, and the strategy will handle the authentication of the user for you.
|
116
136
|
|
117
137
|
### Disabling Automatic Login After Password Resets
|
138
|
+
|
118
139
|
If you use the Devise `recoverable` strategy, the default behavior after a password reset is to automatically authenticate the user and log them in. This is obviously a problem if a user has two-factor authentication enabled, as resetting the password would get around the two-factor requirement.
|
119
140
|
|
120
141
|
Because of this, you need to set `sign_in_after_reset_password` to `false` (either globally in your Devise initializer or via `devise_for`).
|
121
142
|
|
122
143
|
### Enabling Two-Factor Authentication
|
144
|
+
|
123
145
|
Enabling two-factor authentication for a user is easy. For example, if my user model were named User, I could do the following:
|
124
146
|
|
125
147
|
```ruby
|
@@ -150,6 +172,7 @@ current_user.current_otp
|
|
150
172
|
```
|
151
173
|
|
152
174
|
The generated code will be valid for the duration specified by `otp_allowed_drift`. This value can be modified by adding a config in `config/initializers/devise.rb`.
|
175
|
+
|
153
176
|
```ruby
|
154
177
|
Devise.otp_allowed_drift = 240 # value in seconds
|
155
178
|
Devise.setup do |config|
|
@@ -166,13 +189,27 @@ However you decide to handle enrollment, there are a few important consideration
|
|
166
189
|
It sounds like a lot of work, but most of these problems have been very elegantly solved by other people. We recommend taking a look at the excellent workflows used by Heroku and Google for inspiration.
|
167
190
|
|
168
191
|
### Filtering sensitive parameters from the logs
|
192
|
+
|
169
193
|
To prevent two-factor authentication codes from leaking if your application logs get breached, you'll want to filter sensitive parameters from the Rails logs. Add the following to `config/initializers/filter_parameter_logging.rb`:
|
170
194
|
|
171
195
|
```ruby
|
172
196
|
Rails.application.config.filter_parameters += [:otp_attempt]
|
173
197
|
```
|
174
198
|
|
199
|
+
### Preventing Brute-Force Attacks
|
200
|
+
|
201
|
+
With any authentication solution it is also important to protect your users from brute-force attacks. For Devise-Two-Factor specifically if a user's username and password have already been compromised an attacker would be able to try possible TOTP codes and see if they can hit a lucky collision to log in. While Devise-Two-Factor is open-ended by design and cannot solve this for all applications natively there are some possible mitigations to consider. A non-exhaustive list follows:
|
202
|
+
|
203
|
+
1. Use the `lockable` strategy from Devise to lock a user after a certain number of failed login attempts. See https://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Lockable for more information.
|
204
|
+
2. Configure a rate limit for your application, especially on the endpoints used to log in. One such library to accomplish this is [rack-attack](https://rubygems.org/gems/rack-attack).
|
205
|
+
3. When displaying authentication errors hide whether validating a username/password combination failed or a two-factor code failed behind a more generic error message.
|
206
|
+
|
207
|
+
#### Acknowledgements
|
208
|
+
|
209
|
+
Thank you to Christian Reitter (Radically Open Security) and Chris MacNaughton (Centauri Solutions) for reporting the issue.
|
210
|
+
|
175
211
|
## Backup Codes
|
212
|
+
|
176
213
|
Devise-Two-Factor is designed with extensibility in mind. One such extension, `TwoFactorBackupable`, is included and serves as a good example of how to extend this gem. This plugin allows you to add the ability to generate single-use backup codes for a user, which they may use to bypass two-factor authentication, in the event that they lose access to their device.
|
177
214
|
|
178
215
|
To install it, you need to add the `:two_factor_backupable` directive to your model.
|
@@ -187,17 +224,39 @@ You'll also be required to enable the `:two_factor_backupable` strategy, by addi
|
|
187
224
|
manager.default_strategies(:scope => :user).unshift :two_factor_backupable
|
188
225
|
```
|
189
226
|
|
190
|
-
|
227
|
+
### Migration
|
228
|
+
|
229
|
+
The final installation step may be dependent on your version of Rails.
|
230
|
+
|
231
|
+
#### PostgreSQL
|
191
232
|
|
192
233
|
```ruby
|
193
234
|
class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration
|
194
235
|
def change
|
195
|
-
# Change type from :string to :text if using MySQL database
|
196
236
|
add_column :users, :otp_backup_codes, :string, array: true
|
197
237
|
end
|
198
238
|
end
|
199
239
|
```
|
200
240
|
|
241
|
+
#### MySQL
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
# migration
|
245
|
+
class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration
|
246
|
+
def change
|
247
|
+
add_column :users, :otp_backup_codes, :text
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# model
|
252
|
+
class User < ApplicationRecord
|
253
|
+
devise :two_factor_backupable
|
254
|
+
serialize :otp_backup_codes, Array
|
255
|
+
end
|
256
|
+
```
|
257
|
+
|
258
|
+
### Generation
|
259
|
+
|
201
260
|
You can then generate backup codes for a user:
|
202
261
|
|
203
262
|
```ruby
|
@@ -215,23 +274,8 @@ devise :two_factor_backupable, otp_backup_code_length: 32,
|
|
215
274
|
otp_number_of_backup_codes: 10
|
216
275
|
```
|
217
276
|
|
218
|
-
### Help! I'm not using Rails 4.0!
|
219
|
-
Don't worry! `TwoFactorBackupable` stores the backup codes as an array of strings in the database. In Rails 4.0 this is supported natively, but in earlier versions you can use a gem to emulate this behavior: we recommend [activerecord-postgres-array](https://github.com/tlconnor/activerecord-postgres-array).
|
220
|
-
|
221
|
-
You'll then simply have to create a migration to add an array named `otp_backup_codes` to your model. If you use the above gem, this migration might look like:
|
222
|
-
|
223
|
-
```ruby
|
224
|
-
class AddTwoFactorBackupCodesToUsers < ActiveRecord::Migration
|
225
|
-
def change
|
226
|
-
# Change type from :string_array to :text_array if using MySQL database
|
227
|
-
add_column :users, :otp_backup_codes, :string_array
|
228
|
-
end
|
229
|
-
end
|
230
|
-
```
|
231
|
-
|
232
|
-
Now just continue with the setup in the previous section, skipping the generator step.
|
233
|
-
|
234
277
|
## Testing
|
278
|
+
|
235
279
|
Devise-Two-Factor includes shared-examples for both `TwoFactorAuthenticatable` and `TwoFactorBackupable`. Adding the following two lines to the specs for your two-factor enabled models will allow you to test your models for two-factor functionality:
|
236
280
|
|
237
281
|
```ruby
|
@@ -242,6 +286,7 @@ it_behaves_like "two_factor_backupable"
|
|
242
286
|
```
|
243
287
|
|
244
288
|
## Troubleshooting
|
289
|
+
|
245
290
|
If you are using Rails 4.x and Ruby >= 2.7, you may get an error like
|
246
291
|
|
247
292
|
```
|
@@ -251,9 +296,11 @@ Failure/Error: require 'devise'
|
|
251
296
|
NoMethodError:
|
252
297
|
undefined method `new' for BigDecimal:Class
|
253
298
|
```
|
299
|
+
|
254
300
|
see https://github.com/ruby/bigdecimal#which-version-should-you-select and https://github.com/ruby/bigdecimal/issues/127
|
255
301
|
for more details, but you should be able to solve this
|
256
302
|
by explicitly requiring an older version of bigdecimal in your gemfile like
|
257
|
-
|
303
|
+
|
304
|
+
```ruby
|
258
305
|
gem "bigdecimal", "~> 1.4"
|
259
306
|
```
|
data/SECURITY.md
ADDED
data/UPGRADING.md
CHANGED
@@ -59,7 +59,7 @@ This gem must be upgraded **as part of a Rails 7 upgrade**. See [the official Ra
|
|
59
59
|
```
|
60
60
|
1. Add a `legacy_otp_secret` method to your user model e.g. `User`.
|
61
61
|
* This method is used by the gem to find and decode the OTP secret from the legacy database columns.
|
62
|
-
* The implementation shown below works if you set up devise-two-factor with the settings suggested in the [README](
|
62
|
+
* The implementation shown below works if you set up devise-two-factor with the settings suggested in the [OLD README](https://github.com/devise-two-factor/devise-two-factor/blob/8d74f5ee45594bf00e60d5d49eb6fcde82c2d2ba/README.md).
|
63
63
|
* If you have customised the encryption scheme used to store the OTP secret then you will need to update this method to match.
|
64
64
|
* If you are unsure, you should try the method below as is, and if you can still sign in users with OTP enabled then all is well.
|
65
65
|
```ruby
|
@@ -87,7 +87,7 @@ This gem must be upgraded **as part of a Rails 7 upgrade**. See [the official Ra
|
|
87
87
|
cipher_text = raw_cipher_text[0..-17]
|
88
88
|
auth_tag = raw_cipher_text[-16..-1]
|
89
89
|
|
90
|
-
# this
|
90
|
+
# this algorithm lifted from
|
91
91
|
# https://github.com/attr-encrypted/encryptor/blob/master/lib/encryptor.rb#L54
|
92
92
|
|
93
93
|
# create an OpenSSL object which will decrypt the AES cipher with 256 bit
|
@@ -101,7 +101,7 @@ This gem must be upgraded **as part of a Rails 7 upgrade**. See [the official Ra
|
|
101
101
|
cipher.decrypt
|
102
102
|
|
103
103
|
# Use a Password-Based Key Derivation Function to generate the key actually
|
104
|
-
# used for
|
104
|
+
# used for encryption from the key we got as input.
|
105
105
|
cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, hmac_iterations, cipher.key_len)
|
106
106
|
|
107
107
|
# set the Initialization Vector (IV)
|
@@ -190,6 +190,15 @@ This "clean up" phase can happen at the same time as your initial deployment but
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
```
|
193
|
+
1. Remove `otp_secret_encryption_key` from the model setup. This also assumes you successfully ran the rake task in step 1.
|
194
|
+
```ruby
|
195
|
+
# from this:
|
196
|
+
devise :two_factor_authenticatable,
|
197
|
+
otp_secret_encryption_key: ENV['YOUR_ENCRYPTION_KEY_HERE']
|
198
|
+
|
199
|
+
# to this:
|
200
|
+
devise :two_factor_authenticatable
|
201
|
+
```
|
193
202
|
|
194
203
|
# Guide to upgrading from 2.x to 3.x
|
195
204
|
|
data/devise-two-factor.gemspec
CHANGED
@@ -5,12 +5,11 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'devise-two-factor'
|
6
6
|
s.version = DeviseTwoFactor::VERSION.dup
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.
|
8
|
+
s.license = 'MIT'
|
9
9
|
s.summary = 'Barebones two-factor authentication with Devise'
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.authors = ['Shane Wilton']
|
10
|
+
s.homepage = 'https://github.com/devise-two-factor/devise-two-factor'
|
11
|
+
s.description = 'Devise-Two-Factor is a minimalist extension to Devise which offers support for two-factor authentication through the TOTP scheme.'
|
12
|
+
s.authors = ['Quinn Wilton']
|
14
13
|
|
15
14
|
s.cert_chain = [
|
16
15
|
'certs/tinfoil-cacert.pem',
|
@@ -31,5 +30,4 @@ Gem::Specification.new do |s|
|
|
31
30
|
s.add_development_dependency 'bundler', '> 1.0'
|
32
31
|
s.add_development_dependency 'rspec', '> 3'
|
33
32
|
s.add_development_dependency 'simplecov'
|
34
|
-
s.add_development_dependency 'faker'
|
35
33
|
end
|
data/gemfiles/rails_7.0.gemfile
CHANGED
data/lib/devise-two-factor.rb
CHANGED
@@ -31,7 +31,7 @@ module Devise
|
|
31
31
|
end
|
32
32
|
|
33
33
|
Devise.add_module(:two_factor_authenticatable, :route => :session, :strategy => true,
|
34
|
-
:controller => :sessions, :model => true)
|
34
|
+
:controller => :sessions, :model => true, :insert_at => 0)
|
35
35
|
|
36
36
|
Devise.add_module(:two_factor_backupable, :route => :session, :strategy => true,
|
37
37
|
:controller => :sessions, :model => true)
|
@@ -125,7 +125,7 @@ RSpec.shared_examples 'two_factor_authenticatable' do
|
|
125
125
|
|
126
126
|
describe '#otp_provisioning_uri' do
|
127
127
|
let(:otp_secret_length) { subject.class.otp_secret_length }
|
128
|
-
let(:account) {
|
128
|
+
let(:account) { 'user@host.example' }
|
129
129
|
let(:issuer) { 'Tinfoil' }
|
130
130
|
|
131
131
|
it 'should return uri with specified account' do
|
@@ -34,7 +34,7 @@ RSpec.shared_examples 'two_factor_backupable' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'with existing recovery codes' do
|
37
|
-
let(:old_codes) {
|
37
|
+
let(:old_codes) { ['adam', 'betty', 'charles'] }
|
38
38
|
let(:old_codes_hashed) { old_codes.map { |x| Devise::Encryptor.digest(subject.class, x) } }
|
39
39
|
|
40
40
|
before do
|
@@ -21,7 +21,7 @@ module Devise
|
|
21
21
|
|
22
22
|
def validate_otp(resource)
|
23
23
|
return true unless resource.otp_required_for_login
|
24
|
-
return if params[scope]['otp_attempt'].nil?
|
24
|
+
return if params[scope].nil? || params[scope]['otp_attempt'].nil?
|
25
25
|
resource.validate_and_consume_otp!(params[scope]['otp_attempt'])
|
26
26
|
end
|
27
27
|
end
|
@@ -25,6 +25,10 @@ class TwoFactorAuthenticatableDouble
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe ::Devise::Models::TwoFactorAuthenticatable do
|
28
|
+
it 'should be inserted prior to other devise modules' do
|
29
|
+
expect(Devise::ALL.first).to eq(:two_factor_authenticatable)
|
30
|
+
end
|
31
|
+
|
28
32
|
context 'When included in a class' do
|
29
33
|
subject { TwoFactorAuthenticatableDouble.new }
|
30
34
|
|
data/spec/spec_helper.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-two-factor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Quinn Wilton
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
@@ -86,7 +86,7 @@ cert_chain:
|
|
86
86
|
vqIDv6JBG9I16h/HhchntKfM58MI1bNZFBSdZqYOJiL8JIjP8HNIk76Y366ppG29
|
87
87
|
EhBYYg==
|
88
88
|
-----END CERTIFICATE-----
|
89
|
-
date:
|
89
|
+
date: 2024-06-18 00:00:00.000000000 Z
|
90
90
|
dependencies:
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: railties
|
@@ -214,26 +214,14 @@ dependencies:
|
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
|
-
-
|
218
|
-
|
219
|
-
|
220
|
-
requirements:
|
221
|
-
- - ">="
|
222
|
-
- !ruby/object:Gem::Version
|
223
|
-
version: '0'
|
224
|
-
type: :development
|
225
|
-
prerelease: false
|
226
|
-
version_requirements: !ruby/object:Gem::Requirement
|
227
|
-
requirements:
|
228
|
-
- - ">="
|
229
|
-
- !ruby/object:Gem::Version
|
230
|
-
version: '0'
|
231
|
-
description: Barebones two-factor authentication with Devise
|
232
|
-
email: engineers@tinfoilsecurity.com
|
217
|
+
description: Devise-Two-Factor is a minimalist extension to Devise which offers support
|
218
|
+
for two-factor authentication through the TOTP scheme.
|
219
|
+
email:
|
233
220
|
executables: []
|
234
221
|
extensions: []
|
235
222
|
extra_rdoc_files: []
|
236
223
|
files:
|
224
|
+
- ".github/dependabot.yml"
|
237
225
|
- ".github/workflows/ci.yml"
|
238
226
|
- ".gitignore"
|
239
227
|
- ".rspec"
|
@@ -244,18 +232,13 @@ files:
|
|
244
232
|
- LICENSE
|
245
233
|
- README.md
|
246
234
|
- Rakefile
|
235
|
+
- SECURITY.md
|
247
236
|
- UPGRADING.md
|
248
237
|
- certs/tinfoil-cacert.pem
|
249
238
|
- certs/tinfoilsecurity-gems-cert.pem
|
250
239
|
- devise-two-factor.gemspec
|
251
|
-
- gemfiles/rails_4.1.gemfile
|
252
|
-
- gemfiles/rails_4.2.gemfile
|
253
|
-
- gemfiles/rails_5.0.gemfile
|
254
|
-
- gemfiles/rails_5.1.gemfile
|
255
|
-
- gemfiles/rails_5.2.gemfile
|
256
|
-
- gemfiles/rails_6.0.gemfile
|
257
|
-
- gemfiles/rails_6.1.gemfile
|
258
240
|
- gemfiles/rails_7.0.gemfile
|
241
|
+
- gemfiles/rails_7.1.gemfile
|
259
242
|
- lib/devise-two-factor.rb
|
260
243
|
- lib/devise_two_factor/models.rb
|
261
244
|
- lib/devise_two_factor/models/two_factor_authenticatable.rb
|
@@ -271,11 +254,11 @@ files:
|
|
271
254
|
- spec/devise/models/two_factor_authenticatable_spec.rb
|
272
255
|
- spec/devise/models/two_factor_backupable_spec.rb
|
273
256
|
- spec/spec_helper.rb
|
274
|
-
homepage: https://github.com/
|
257
|
+
homepage: https://github.com/devise-two-factor/devise-two-factor
|
275
258
|
licenses:
|
276
259
|
- MIT
|
277
260
|
metadata: {}
|
278
|
-
post_install_message:
|
261
|
+
post_install_message:
|
279
262
|
rdoc_options: []
|
280
263
|
require_paths:
|
281
264
|
- lib
|
@@ -290,8 +273,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
273
|
- !ruby/object:Gem::Version
|
291
274
|
version: '0'
|
292
275
|
requirements: []
|
293
|
-
rubygems_version: 3.
|
294
|
-
signing_key:
|
276
|
+
rubygems_version: 3.0.3.1
|
277
|
+
signing_key:
|
295
278
|
specification_version: 4
|
296
279
|
summary: Barebones two-factor authentication with Devise
|
297
280
|
test_files:
|
metadata.gz.sig
CHANGED
Binary file
|
data/gemfiles/rails_4.2.gemfile
DELETED
data/gemfiles/rails_5.0.gemfile
DELETED
data/gemfiles/rails_5.1.gemfile
DELETED
data/gemfiles/rails_5.2.gemfile
DELETED
data/gemfiles/rails_6.0.gemfile
DELETED