Skip to content

Commit 5bfa27c

Browse files
authored
Merge pull request #7 from jayywolff/specs
Add Appraisals for testing against Rails 7 & 7.1
2 parents aeaba85 + 151e4ea commit 5bfa27c

File tree

9 files changed

+118
-55
lines changed

9 files changed

+118
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ gemfiles/*.lock
3737
.rvmrc
3838

3939
**/*.sqlite
40+
**/*.sqlite-*
4041
**/*.log
4142

4243
initializers/twilio_verify.rb

Appraisals

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ appraise "rails-5-2" do
33
gem "sqlite3", "~> 1.3.13"
44

55
group :development, :test do
6-
gem 'factory_girl_rails', :require => false
7-
gem 'rspec-rails', "~>4.0.0.beta3", :require => false
8-
gem 'database_cleaner', :require => false
6+
gem 'factory_girl_rails', require: false
7+
gem 'rspec-rails', "~> 5.0.0", require: false
8+
gem 'database_cleaner', require: false
99
end
1010
end if RUBY_VERSION.to_f < 3.0
1111

@@ -15,8 +15,32 @@ appraise "rails-6" do
1515
gem "net-smtp"
1616

1717
group :development, :test do
18-
gem 'factory_girl_rails', :require => false
19-
gem 'rspec-rails', "~>4.0.0.beta3", :require => false
20-
gem 'database_cleaner', :require => false
18+
gem 'factory_girl_rails', require: false
19+
gem 'rspec-rails', "~> 5.0.0", require: false
20+
gem 'database_cleaner', require: false
2121
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

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

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+
816
## [0.2.0] - 2024-12-21
917

1018
### Changed

README.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
# Migrate Authy to Twilio Verify API (for SMS and TOTP 2FA)
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-
421
# Twilio Verify Devise [![Build Status](https://github.com/jayywolff/twilio-verify-devise/workflows/build/badge.svg)](https://github.com/jayywolff/twilio-verify-devise/actions)
432

443
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.
@@ -48,10 +7,9 @@ Please visit the Twilio Docs for more information:
487
* [Verify + Ruby (Rails) quickstart](https://www.twilio.com/docs/verify/quickstarts/ruby-rails)
498
* [Twilio Ruby helper library](https://www.twilio.com/docs/libraries/ruby)
509
* [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)
5311
* [Pre-requisites](#pre-requisites)
54-
* [Demo](#demo)
12+
* [Demo (TODO)](#demo)
5513
* [Getting started](#getting-started)
5614
* [Configuring Models](#configuring-models)
5715
* [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
246204

247205
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.
248206

249-
To remedy this, add `prepend: true` to your `protect_from_forgery` call, like in this example from the [Twilio Verify Devise demo app](https://github.com/twilio/authy-devise-demo):
207+
To remedy this, add `prepend: true` to your `protect_from_forgery` call
250208

251209
```ruby
252210
class ApplicationController < ActionController::Base
@@ -262,5 +220,47 @@ Run the following command:
262220
$ bundle exec rspec
263221
```
264222

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+
265265
## Copyright
266266
See LICENSE.txt for further details.

gemfiles/rails_5_2.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem "sqlite3", "~> 1.3.13"
77

88
group :development, :test do
99
gem "factory_girl_rails", require: false
10-
gem "rspec-rails", "~>4.0.0.beta3", require: false
10+
gem "rspec-rails", "~> 5.0.0", require: false
1111
gem "database_cleaner", require: false
1212
end
1313

gemfiles/rails_6.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gem "net-smtp"
88

99
group :development, :test do
1010
gem "factory_girl_rails", require: false
11-
gem "rspec-rails", "~>4.0.0.beta3", require: false
11+
gem "rspec-rails", "~> 5.0.0", require: false
1212
gem "database_cleaner", require: false
1313
end
1414

gemfiles/rails_7.gemfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: "../"

gemfiles/rails_7_1.gemfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: "../"

lib/devise-twilio-verify/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module DeviseTwilioVerify
4-
VERSION = '0.2.0'
4+
VERSION = '0.2.1'
55
end

0 commit comments

Comments
 (0)