devise-twilio-verify 0.1.1 → 0.2.1
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/.github/workflows/build.yml +5 -1
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/Appraisals +31 -7
- data/CHANGELOG.md +17 -0
- data/README.md +46 -46
- data/app/controllers/devise/devise_twilio_verify_controller.rb +19 -4
- data/devise-twilio-verify.gemspec +3 -0
- data/gemfiles/rails_5_2.gemfile +1 -1
- data/gemfiles/rails_6.gemfile +1 -1
- data/gemfiles/rails_7.gemfile +15 -0
- data/gemfiles/rails_7_1.gemfile +15 -0
- data/lib/devise-twilio-verify/models/twilio_verify_authenticatable.rb +2 -0
- data/lib/devise-twilio-verify/version.rb +1 -1
- data/lib/generators/active_record/templates/migration.rb +2 -3
- metadata +46 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a714eac102e58b29a7fbf76bffd98074b7a3762cabe8a45bd728c0e3c6dae5
|
4
|
+
data.tar.gz: e4089d64477e6f9e0d0c64f7066e532a59fc762cfba3562ff0af898b5838520e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c5a2757ee1bebd13c8bab15672d097348619900020961fb0c835fdc5fa16fdcce570862a66ab187bfa4ed9b7f6b37573fc5a9e7b6c2bc1e350a22f4819cc1f
|
7
|
+
data.tar.gz: a16f7741281e5f4a01c2c318f25d32669739d45df8fbfca1efa151ebdafb7cdd36f117c45b484d5b91a7e3fa04b8c3424245200dd2fdb8c83769e1844a260326
|
data/.github/workflows/build.yml
CHANGED
@@ -8,13 +8,17 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
|
-
ruby: [2.
|
11
|
+
ruby: [2.7, "3.0", 3.1, 3.2, 3.3, head]
|
12
12
|
gemfile: [rails_5_2, rails_6]
|
13
13
|
exclude:
|
14
14
|
- ruby: "3.0"
|
15
15
|
gemfile: rails_5_2
|
16
16
|
- ruby: 3.1
|
17
17
|
gemfile: rails_5_2
|
18
|
+
- ruby: 3.2
|
19
|
+
gemfile: rails_5_2
|
20
|
+
- ruby: 3.3
|
21
|
+
gemfile: rails_5_2
|
18
22
|
- ruby: head
|
19
23
|
gemfile: rails_5_2
|
20
24
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--color
|
2
|
-
--require ./spec/spec_helper
|
2
|
+
--require ./spec/spec_helper
|
data/Appraisals
CHANGED
@@ -3,9 +3,9 @@ appraise "rails-5-2" do
|
|
3
3
|
gem "sqlite3", "~> 1.3.13"
|
4
4
|
|
5
5
|
group :development, :test do
|
6
|
-
gem 'factory_girl_rails', :
|
7
|
-
gem 'rspec-rails', "~>
|
8
|
-
gem 'database_cleaner', :
|
6
|
+
gem 'factory_girl_rails', require: false
|
7
|
+
gem 'rspec-rails', "~> 5.0.0", require: false
|
8
|
+
gem 'database_cleaner', require: false
|
9
9
|
end
|
10
10
|
end if RUBY_VERSION.to_f < 3.0
|
11
11
|
|
@@ -15,8 +15,32 @@ appraise "rails-6" do
|
|
15
15
|
gem "net-smtp"
|
16
16
|
|
17
17
|
group :development, :test do
|
18
|
-
gem 'factory_girl_rails', :
|
19
|
-
gem 'rspec-rails', "~>
|
20
|
-
gem 'database_cleaner', :
|
18
|
+
gem 'factory_girl_rails', require: false
|
19
|
+
gem 'rspec-rails', "~> 5.0.0", require: false
|
20
|
+
gem 'database_cleaner', require: false
|
21
21
|
end
|
22
|
-
end if RUBY_VERSION.to_f >= 2.5
|
22
|
+
end if RUBY_VERSION.to_f >= 2.5
|
23
|
+
|
24
|
+
appraise "rails-7" do
|
25
|
+
gem "rails", "~> 7.0.8"
|
26
|
+
gem "sqlite3", "~> 1.4"
|
27
|
+
gem "net-smtp"
|
28
|
+
|
29
|
+
group :development, :test do
|
30
|
+
gem 'factory_girl_rails', require: false
|
31
|
+
gem 'rspec-rails', "~> 7.0.0", require: false
|
32
|
+
gem 'database_cleaner', require: false
|
33
|
+
end
|
34
|
+
end if RUBY_VERSION.to_f >= 2.7
|
35
|
+
|
36
|
+
appraise "rails-7-1" do
|
37
|
+
gem "rails", "~> 7.1.5"
|
38
|
+
gem "sqlite3", "~> 1.4"
|
39
|
+
gem "net-smtp"
|
40
|
+
|
41
|
+
group :development, :test do
|
42
|
+
gem 'factory_girl_rails', require: false
|
43
|
+
gem 'rspec-rails', "~> 7.1.0", require: false
|
44
|
+
gem 'database_cleaner', require: false
|
45
|
+
end
|
46
|
+
end if RUBY_VERSION.to_f >= 2.7
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.2.1] - 2024-12-29
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Added apprasials for testing against Rails 7 and Rails 7.1
|
13
|
+
- Bump rspec-rails version from "~>4.0.0.beta3" to "~> 5.0.0" for Rails 5.2 and Rails 6 testing
|
14
|
+
- Updated README to move the authy migration instructions a bit below the README gem introduction / instructions
|
15
|
+
|
16
|
+
## [0.2.0] - 2024-12-21
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- Bugfix to not return any users when the mobile phone number is missing when querying for a user with `User.find_by_mobile_phone`
|
21
|
+
- Fixed test coverage from the initial fork from Authy to Twilio Verify API
|
22
|
+
- Disabled specs for TOTP setup. Currently there's just a method exposed to generate a code with the Twilio Verify service. Rails apps consuming the gem are expected to to generate a qr code with this code and present it to the user to scan. This feature can be added in the future
|
23
|
+
- Restored original flash message behavior from authy-devise on a few endpoints. Despite this being the original behavior, due to this change I will bump versioning as minor version release for Rails apps that did not migrate from devise-authy
|
24
|
+
|
8
25
|
## [0.1.1] - 2023-04-12
|
9
26
|
|
10
27
|
### Changed
|
data/README.md
CHANGED
@@ -1,45 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
### This gem is meant to be a drop-in replacement for devise-authy in a Rails app (minus the following features)
|
4
|
-
- Currently only support mobile phones with US country codes
|
5
|
-
- Removed Onetouch support
|
6
|
-
- Removed ability to request a phone call
|
7
|
-
|
8
|
-
### Just follow the steps below to migrate:
|
9
|
-
- Swap out `devise-authy` in your Gemfile with `devise-twilio-verify`
|
10
|
-
- `gem 'devise-twilio-verify'
|
11
|
-
- Setup a Twilio Verify account
|
12
|
-
- Add env vars and/or Rails credentials for:
|
13
|
-
- `TWILIO_AUTH_TOKEN`
|
14
|
-
- `TWILIO_ACCOUNT_SID`
|
15
|
-
- `TWILIO_VERIFY_SERVICE_SID`
|
16
|
-
- Create/run a migration to rename and add the following columns
|
17
|
-
```ruby
|
18
|
-
class MigrateAuthyToTwilioVerify < ActiveRecord::Migration[6.1]
|
19
|
-
def change
|
20
|
-
rename_column :users, :authy_sms, :twilio_verify_sms
|
21
|
-
rename_column :users, :authy_enabled, :twilio_verify_enabled
|
22
|
-
rename_column :users, :last_sign_in_with_authy, :last_sign_in_with_twilio_verify
|
23
|
-
add_column :users, :twilio_totp_factor_sid, :string
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
```
|
28
|
-
- you can also delete the `users.authy_id` column if you choose
|
29
|
-
- Twilio Verify service sms will be sent to `users.mobile_phone`, so make sure you store the users 2fa phone number in this column, can make this field name dynamic in the future
|
30
|
-
- Do a project code wide search & replace of these terms
|
31
|
-
- `devise-authy` -> `devise-twilio-verify`
|
32
|
-
- `authy_` -> `twilio_verify_`
|
33
|
-
- `_authy` -> `_twilio_verify`
|
34
|
-
- `authy-` -> `twilio-verify-`
|
35
|
-
- `-authy` -> `-twilio-verify`
|
36
|
-
- `Authy` -> `TwilioVerify`
|
37
|
-
- Do a project file search & replace of any file with authy in the name (here's a few examples to replace)
|
38
|
-
- app/javascript/src/deviseTwilioVerify.js
|
39
|
-
- app/assets/stylesheets/devise_twilio_verify.scss
|
40
|
-
- config/locales/devise.twilio_verify.en.yml
|
41
|
-
|
42
|
-
# Twilio Verify Devise [](https://github.com/twilio/authy-devise/actions)
|
1
|
+
# Twilio Verify Devise [](https://github.com/jayywolff/twilio-verify-devise/actions)
|
43
2
|
|
44
3
|
This is a [Devise](https://github.com/heartcombo/devise) extension to add [Two-Factor Authentication with Twilio Verify](https://www.twilio.com/docs/verify) to your Rails application.
|
45
4
|
|
@@ -48,10 +7,9 @@ Please visit the Twilio Docs for more information:
|
|
48
7
|
* [Verify + Ruby (Rails) quickstart](https://www.twilio.com/docs/verify/quickstarts/ruby-rails)
|
49
8
|
* [Twilio Ruby helper library](https://www.twilio.com/docs/libraries/ruby)
|
50
9
|
* [Verify API reference](https://www.twilio.com/docs/verify/api)
|
51
|
-
|
52
|
-
|
10
|
+
* [Migrate Authy to Twilio Verify API](#migrate-authy-to-twilio-verify-api)
|
53
11
|
* [Pre-requisites](#pre-requisites)
|
54
|
-
* [Demo](#demo)
|
12
|
+
* [Demo (TODO)](#demo)
|
55
13
|
* [Getting started](#getting-started)
|
56
14
|
* [Configuring Models](#configuring-models)
|
57
15
|
* [With the generator](#with-the-generator)
|
@@ -246,7 +204,7 @@ This will display a QR code on the verification screen (you still need to take a
|
|
246
204
|
|
247
205
|
In Rails 5 `protect_from_forgery` is no longer prepended to the `before_action` chain. If you call `authenticate_user` before `protect_from_forgery` your request will result in a "Can't verify CSRF token authenticity" error.
|
248
206
|
|
249
|
-
To remedy this, add `prepend: true` to your `protect_from_forgery` call
|
207
|
+
To remedy this, add `prepend: true` to your `protect_from_forgery` call
|
250
208
|
|
251
209
|
```ruby
|
252
210
|
class ApplicationController < ActionController::Base
|
@@ -262,5 +220,47 @@ Run the following command:
|
|
262
220
|
$ bundle exec rspec
|
263
221
|
```
|
264
222
|
|
223
|
+
## Migrate Authy to Twilio Verify API
|
224
|
+
|
225
|
+
### This gem is meant to be a drop-in replacement for devise-authy in a Rails app (minus the following features)
|
226
|
+
- Currently supports SMS and TOTP 2FA
|
227
|
+
- Currently only support mobile phones with US country codes
|
228
|
+
- Removed Onetouch support
|
229
|
+
- Removed ability to request a phone call
|
230
|
+
|
231
|
+
### Just follow the steps below to migrate:
|
232
|
+
- Swap out `devise-authy` in your Gemfile with `devise-twilio-verify`
|
233
|
+
- `gem 'devise-twilio-verify'
|
234
|
+
- Setup a Twilio Verify account
|
235
|
+
- Add env vars and/or Rails credentials for:
|
236
|
+
- `TWILIO_AUTH_TOKEN`
|
237
|
+
- `TWILIO_ACCOUNT_SID`
|
238
|
+
- `TWILIO_VERIFY_SERVICE_SID`
|
239
|
+
- Create/run a migration to rename and add the following columns
|
240
|
+
```ruby
|
241
|
+
class MigrateAuthyToTwilioVerify < ActiveRecord::Migration[6.1]
|
242
|
+
def change
|
243
|
+
rename_column :users, :authy_sms, :twilio_verify_sms
|
244
|
+
rename_column :users, :authy_enabled, :twilio_verify_enabled
|
245
|
+
rename_column :users, :last_sign_in_with_authy, :last_sign_in_with_twilio_verify
|
246
|
+
add_column :users, :twilio_totp_factor_sid, :string
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
```
|
251
|
+
- you can also delete the `users.authy_id` column if you choose
|
252
|
+
- Twilio Verify service sms will be sent to `users.mobile_phone`, so make sure you store the users 2fa phone number in this column, can make this field name dynamic in the future
|
253
|
+
- Do a project code wide search & replace of these terms
|
254
|
+
- `devise-authy` -> `devise-twilio-verify`
|
255
|
+
- `authy_` -> `twilio_verify_`
|
256
|
+
- `_authy` -> `_twilio_verify`
|
257
|
+
- `authy-` -> `twilio-verify-`
|
258
|
+
- `-authy` -> `-twilio-verify`
|
259
|
+
- `Authy` -> `TwilioVerify`
|
260
|
+
- Do a project file search & replace of any file with authy in the name (here's a few examples to replace)
|
261
|
+
- app/javascript/src/deviseTwilioVerify.js
|
262
|
+
- app/assets/stylesheets/devise_twilio_verify.scss
|
263
|
+
- config/locales/devise.twilio_verify.en.yml
|
264
|
+
|
265
265
|
## Copyright
|
266
266
|
See LICENSE.txt for further details.
|
@@ -34,7 +34,7 @@ class Devise::DeviseTwilioVerifyController < DeviseController
|
|
34
34
|
verification_check = false
|
35
35
|
end
|
36
36
|
|
37
|
-
#
|
37
|
+
# Reproduce authy functionality of being able to verify 2FA via SMS or TOTP
|
38
38
|
# not ideal as there could be network delays, but there is currently no alternative
|
39
39
|
if !verification_check && @resource.twilio_totp_factor_sid.present?
|
40
40
|
verification_check = TwilioVerifyService.verify_totp_token(@resource, params[:token])
|
@@ -51,6 +51,15 @@ class Devise::DeviseTwilioVerifyController < DeviseController
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def GET_enable_twilio_verify
|
55
|
+
if resource.twilio_verify_enabled?
|
56
|
+
set_flash_message(:notice, :already_enabled)
|
57
|
+
redirect_to after_twilio_verify_enabled_path_for(resource)
|
58
|
+
else
|
59
|
+
render :enable_twilio_verify
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
54
63
|
# enable 2fa
|
55
64
|
def POST_enable_twilio_verify
|
56
65
|
if resource.update(twilio_verify_enabled: true)
|
@@ -64,7 +73,13 @@ class Devise::DeviseTwilioVerifyController < DeviseController
|
|
64
73
|
# Disable 2FA
|
65
74
|
def POST_disable_twilio_verify
|
66
75
|
resource.assign_attributes(twilio_verify_enabled: false)
|
67
|
-
resource.save(:
|
76
|
+
if resource.save(validate: false)
|
77
|
+
forget_device
|
78
|
+
set_flash_message(:notice, :disabled)
|
79
|
+
else
|
80
|
+
set_flash_message(:error, :not_disabled)
|
81
|
+
end
|
82
|
+
|
68
83
|
redirect_to after_twilio_verify_disabled_path_for(resource)
|
69
84
|
end
|
70
85
|
|
@@ -83,9 +98,9 @@ class Devise::DeviseTwilioVerifyController < DeviseController
|
|
83
98
|
|
84
99
|
verification_check = TwilioVerifyService.verify_sms_token(@resource.mobile_phone, params[:token])
|
85
100
|
|
86
|
-
self.resource.twilio_verify_enabled =
|
101
|
+
self.resource.twilio_verify_enabled = verification_check.status == 'approved'
|
87
102
|
|
88
|
-
if
|
103
|
+
if verification_check.status == 'approved' && self.resource.save
|
89
104
|
remember_device(@resource.id) if params[:remember_device].to_i == 1
|
90
105
|
record_twilio_verify_authentication
|
91
106
|
set_flash_message(:notice, :enabled)
|
@@ -46,4 +46,7 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_development_dependency "generator_spec"
|
47
47
|
spec.add_development_dependency "database_cleaner", "~> 1.7"
|
48
48
|
spec.add_development_dependency "factory_bot_rails", "~> 5.1.1"
|
49
|
+
spec.add_development_dependency "mutex_m", "~> 0.3.0"
|
50
|
+
spec.add_development_dependency "drb", "~> 2.2.1"
|
51
|
+
spec.add_development_dependency "observer", "~> 0.1.2"
|
49
52
|
end
|
data/gemfiles/rails_5_2.gemfile
CHANGED
data/gemfiles/rails_6.gemfile
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 7.0.8"
|
6
|
+
gem "sqlite3", "~> 1.4"
|
7
|
+
gem "net-smtp"
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem "factory_girl_rails", require: false
|
11
|
+
gem "rspec-rails", "~> 7.0.0", require: false
|
12
|
+
gem "database_cleaner", require: false
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 7.1.5"
|
6
|
+
gem "sqlite3", "~> 1.4"
|
7
|
+
gem "net-smtp"
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem "factory_girl_rails", require: false
|
11
|
+
gem "rspec-rails", "~> 7.1.0", require: false
|
12
|
+
gem "database_cleaner", require: false
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -4,14 +4,13 @@ class DeviseTwilioVerifyAddTo<%= table_name.camelize %> < ActiveRecord::Migratio
|
|
4
4
|
t.string :authy_id
|
5
5
|
t.datetime :last_sign_in_with_twilio_verify
|
6
6
|
t.boolean :twilio_verify_enabled, :default => false
|
7
|
+
t.string :twilio_totp_factor_sid
|
7
8
|
end
|
8
|
-
|
9
|
-
add_index :<%= table_name %>, :authy_id
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.down
|
13
12
|
change_table :<%= table_name %> do |t|
|
14
|
-
t.remove :authy_id, :last_sign_in_with_twilio_verify, :twilio_verify_enabled
|
13
|
+
t.remove :authy_id, :last_sign_in_with_twilio_verify, :twilio_verify_enabled, :twilio_totp_factor_sid
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-twilio-verify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Wolff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -262,6 +262,48 @@ dependencies:
|
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: 5.1.1
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: mutex_m
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: 0.3.0
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: 0.3.0
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: drb
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - "~>"
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: 2.2.1
|
286
|
+
type: :development
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - "~>"
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: 2.2.1
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: observer
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - "~>"
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: 0.1.2
|
300
|
+
type: :development
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - "~>"
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: 0.1.2
|
265
307
|
description: Twilio Verify plugin to add two factor authentication to Devise. This
|
266
308
|
gem is meant to make migrating from authy to twilio verify as simple as possible,
|
267
309
|
please see the README for details.
|
@@ -298,6 +340,8 @@ files:
|
|
298
340
|
- gemfiles/.bundle/config
|
299
341
|
- gemfiles/rails_5_2.gemfile
|
300
342
|
- gemfiles/rails_6.gemfile
|
343
|
+
- gemfiles/rails_7.gemfile
|
344
|
+
- gemfiles/rails_7_1.gemfile
|
301
345
|
- lib/devise-twilio-verify.rb
|
302
346
|
- lib/devise-twilio-verify/controllers/helpers.rb
|
303
347
|
- lib/devise-twilio-verify/controllers/view_helpers.rb
|