devise-authy 1.7.0 → 2.3.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.
Files changed (180) hide show
  1. checksums.yaml +5 -13
  2. data/.github/workflows/build.yml +32 -0
  3. data/.gitignore +45 -0
  4. data/.rspec +1 -0
  5. data/Appraisals +22 -0
  6. data/CHANGELOG.md +152 -0
  7. data/Gemfile +2 -23
  8. data/LICENSE.txt +1 -1
  9. data/README.md +147 -36
  10. data/Rakefile +1 -14
  11. data/app/controllers/devise/devise_authy_controller.rb +90 -30
  12. data/app/controllers/devise_authy/passwords_controller.rb +18 -0
  13. data/app/views/devise/enable_authy.html.erb +2 -2
  14. data/app/views/devise/enable_authy.html.haml +2 -2
  15. data/app/views/devise/verify_authy.html.erb +23 -6
  16. data/app/views/devise/verify_authy.html.haml +21 -6
  17. data/app/views/devise/verify_authy_installation.html.erb +14 -6
  18. data/app/views/devise/verify_authy_installation.html.haml +12 -4
  19. data/config/locales/en.yml +8 -4
  20. data/config.ru +9 -0
  21. data/devise-authy.gemspec +44 -239
  22. data/gemfiles/.bundle/config +2 -0
  23. data/gemfiles/rails_5_2.gemfile +14 -0
  24. data/gemfiles/rails_6.gemfile +15 -0
  25. data/lib/devise-authy/controllers/helpers.rb +31 -12
  26. data/lib/devise-authy/controllers/view_helpers.rb +13 -7
  27. data/lib/devise-authy/mapping.rb +10 -7
  28. data/lib/devise-authy/models/authy_authenticatable.rb +2 -2
  29. data/lib/devise-authy/rails.rb +1 -1
  30. data/lib/devise-authy/routes.rb +3 -2
  31. data/lib/devise-authy/version.rb +5 -0
  32. data/lib/devise-authy.rb +8 -1
  33. data/lib/generators/active_record/devise_authy_generator.rb +11 -1
  34. data/lib/generators/active_record/templates/migration.rb +1 -1
  35. data/lib/generators/devise_authy/devise_authy_generator.rb +8 -8
  36. data/lib/generators/devise_authy/install_generator.rb +19 -5
  37. metadata +173 -205
  38. data/Gemfile.lock +0 -194
  39. data/VERSION +0 -1
  40. data/authy-devise-demo/.gitignore +0 -15
  41. data/authy-devise-demo/Gemfile +0 -40
  42. data/authy-devise-demo/Gemfile.lock +0 -141
  43. data/authy-devise-demo/README.md +0 -64
  44. data/authy-devise-demo/Rakefile +0 -7
  45. data/authy-devise-demo/app/assets/images/rails.png +0 -0
  46. data/authy-devise-demo/app/assets/javascripts/application.js +0 -15
  47. data/authy-devise-demo/app/assets/javascripts/devise_authy.js +0 -12
  48. data/authy-devise-demo/app/assets/javascripts/welcome.js.coffee +0 -3
  49. data/authy-devise-demo/app/assets/stylesheets/application.css +0 -13
  50. data/authy-devise-demo/app/assets/stylesheets/devise_authy.css +0 -26
  51. data/authy-devise-demo/app/assets/stylesheets/welcome.css.scss +0 -3
  52. data/authy-devise-demo/app/controllers/application_controller.rb +0 -3
  53. data/authy-devise-demo/app/controllers/welcome_controller.rb +0 -15
  54. data/authy-devise-demo/app/helpers/application_helper.rb +0 -2
  55. data/authy-devise-demo/app/helpers/welcome_helper.rb +0 -2
  56. data/authy-devise-demo/app/mailers/.gitkeep +0 -0
  57. data/authy-devise-demo/app/models/.gitkeep +0 -0
  58. data/authy-devise-demo/app/models/admin.rb +0 -10
  59. data/authy-devise-demo/app/models/user.rb +0 -10
  60. data/authy-devise-demo/app/views/devise/devise_authy/enable_authy.html.erb +0 -7
  61. data/authy-devise-demo/app/views/devise/devise_authy/verify_authy.html.erb +0 -22
  62. data/authy-devise-demo/app/views/devise/devise_authy/verify_authy_installation.html.erb +0 -10
  63. data/authy-devise-demo/app/views/layouts/application.html.erb +0 -28
  64. data/authy-devise-demo/app/views/welcome/admin_page.html.erb +0 -12
  65. data/authy-devise-demo/app/views/welcome/index.html.erb +0 -5
  66. data/authy-devise-demo/app/views/welcome/user_page.html.erb +0 -5
  67. data/authy-devise-demo/config/application.rb +0 -62
  68. data/authy-devise-demo/config/boot.rb +0 -6
  69. data/authy-devise-demo/config/database.yml +0 -25
  70. data/authy-devise-demo/config/environment.rb +0 -5
  71. data/authy-devise-demo/config/environments/development.rb +0 -39
  72. data/authy-devise-demo/config/environments/production.rb +0 -67
  73. data/authy-devise-demo/config/environments/test.rb +0 -37
  74. data/authy-devise-demo/config/initializers/authy.rb +0 -1
  75. data/authy-devise-demo/config/initializers/backtrace_silencers.rb +0 -7
  76. data/authy-devise-demo/config/initializers/devise.rb +0 -237
  77. data/authy-devise-demo/config/initializers/inflections.rb +0 -15
  78. data/authy-devise-demo/config/initializers/mime_types.rb +0 -5
  79. data/authy-devise-demo/config/initializers/secret_token.rb +0 -7
  80. data/authy-devise-demo/config/initializers/session_store.rb +0 -8
  81. data/authy-devise-demo/config/initializers/wrap_parameters.rb +0 -14
  82. data/authy-devise-demo/config/locales/devise.authy.en.yml +0 -24
  83. data/authy-devise-demo/config/locales/devise.en.yml +0 -58
  84. data/authy-devise-demo/config/locales/en.yml +0 -5
  85. data/authy-devise-demo/config/routes.rb +0 -65
  86. data/authy-devise-demo/config.ru +0 -4
  87. data/authy-devise-demo/db/migrate/20130409234357_devise_create_users.rb +0 -46
  88. data/authy-devise-demo/db/migrate/20141202000744_devise_create_admins.rb +0 -46
  89. data/authy-devise-demo/db/migrate/20141202004246_devise_authy_add_to_admins.rb +0 -21
  90. data/authy-devise-demo/db/schema.rb +0 -62
  91. data/authy-devise-demo/db/seeds.rb +0 -7
  92. data/authy-devise-demo/lib/assets/.gitkeep +0 -0
  93. data/authy-devise-demo/lib/tasks/.gitkeep +0 -0
  94. data/authy-devise-demo/log/.gitkeep +0 -0
  95. data/authy-devise-demo/public/404.html +0 -26
  96. data/authy-devise-demo/public/422.html +0 -26
  97. data/authy-devise-demo/public/500.html +0 -25
  98. data/authy-devise-demo/public/favicon.ico +0 -0
  99. data/authy-devise-demo/public/robots.txt +0 -5
  100. data/authy-devise-demo/script/rails +0 -6
  101. data/authy-devise-demo/test/fixtures/.gitkeep +0 -0
  102. data/authy-devise-demo/test/fixtures/users.yml +0 -11
  103. data/authy-devise-demo/test/functional/.gitkeep +0 -0
  104. data/authy-devise-demo/test/functional/welcome_controller_test.rb +0 -9
  105. data/authy-devise-demo/test/integration/.gitkeep +0 -0
  106. data/authy-devise-demo/test/performance/browsing_test.rb +0 -12
  107. data/authy-devise-demo/test/test_helper.rb +0 -13
  108. data/authy-devise-demo/test/unit/.gitkeep +0 -0
  109. data/authy-devise-demo/test/unit/helpers/welcome_helper_test.rb +0 -4
  110. data/authy-devise-demo/test/unit/user_test.rb +0 -7
  111. data/authy-devise-demo/vendor/assets/javascripts/.gitkeep +0 -0
  112. data/authy-devise-demo/vendor/assets/stylesheets/.gitkeep +0 -0
  113. data/authy-devise-demo/vendor/plugins/.gitkeep +0 -0
  114. data/spec/controllers/devise_authy_controller_spec.rb +0 -271
  115. data/spec/controllers/passwords_controller_spec.rb +0 -48
  116. data/spec/features/authy_authenticatable_spec.rb +0 -90
  117. data/spec/features/authy_lockable_spec.rb +0 -70
  118. data/spec/generators_spec.rb +0 -30
  119. data/spec/models/authy_authenticatable_spec.rb +0 -17
  120. data/spec/models/authy_lockable_spec.rb +0 -81
  121. data/spec/orm/active_record.rb +0 -4
  122. data/spec/rails-app/Gemfile +0 -9
  123. data/spec/rails-app/Gemfile.lock +0 -115
  124. data/spec/rails-app/Rakefile +0 -7
  125. data/spec/rails-app/app/assets/images/rails.png +0 -0
  126. data/spec/rails-app/app/assets/javascripts/application.js +0 -15
  127. data/spec/rails-app/app/assets/javascripts/devise_authy.js +0 -12
  128. data/spec/rails-app/app/assets/javascripts/welcome.js +0 -2
  129. data/spec/rails-app/app/assets/stylesheets/application.css +0 -13
  130. data/spec/rails-app/app/assets/stylesheets/devise_authy.css +0 -26
  131. data/spec/rails-app/app/assets/stylesheets/welcome.css.scss +0 -3
  132. data/spec/rails-app/app/controllers/application_controller.rb +0 -3
  133. data/spec/rails-app/app/controllers/welcome_controller.rb +0 -13
  134. data/spec/rails-app/app/helpers/application_helper.rb +0 -2
  135. data/spec/rails-app/app/helpers/welcome_helper.rb +0 -2
  136. data/spec/rails-app/app/mailers/.gitkeep +0 -0
  137. data/spec/rails-app/app/models/.gitkeep +0 -0
  138. data/spec/rails-app/app/models/lockable_user.rb +0 -7
  139. data/spec/rails-app/app/models/user.rb +0 -11
  140. data/spec/rails-app/app/views/devise/devise_authy/enable_authy.html.erb +0 -7
  141. data/spec/rails-app/app/views/devise/devise_authy/verify_authy.html.erb +0 -21
  142. data/spec/rails-app/app/views/devise/devise_authy/verify_authy_installation.html.erb +0 -10
  143. data/spec/rails-app/app/views/layouts/application.html.erb +0 -28
  144. data/spec/rails-app/app/views/welcome/index.html.erb +0 -5
  145. data/spec/rails-app/config/application.rb +0 -49
  146. data/spec/rails-app/config/boot.rb +0 -6
  147. data/spec/rails-app/config/database.yml +0 -25
  148. data/spec/rails-app/config/environment.rb +0 -5
  149. data/spec/rails-app/config/environments/development.rb +0 -39
  150. data/spec/rails-app/config/environments/production.rb +0 -67
  151. data/spec/rails-app/config/environments/test.rb +0 -39
  152. data/spec/rails-app/config/initializers/authy.rb +0 -2
  153. data/spec/rails-app/config/initializers/backtrace_silencers.rb +0 -7
  154. data/spec/rails-app/config/initializers/devise.rb +0 -245
  155. data/spec/rails-app/config/initializers/inflections.rb +0 -15
  156. data/spec/rails-app/config/initializers/mime_types.rb +0 -5
  157. data/spec/rails-app/config/initializers/secret_token.rb +0 -7
  158. data/spec/rails-app/config/initializers/session_store.rb +0 -8
  159. data/spec/rails-app/config/initializers/wrap_parameters.rb +0 -14
  160. data/spec/rails-app/config/locales/devise.authy.en.yml +0 -24
  161. data/spec/rails-app/config/locales/devise.en.yml +0 -59
  162. data/spec/rails-app/config/locales/en.yml +0 -5
  163. data/spec/rails-app/config/routes.rb +0 -8
  164. data/spec/rails-app/config.ru +0 -4
  165. data/spec/rails-app/db/development.sqlite3 +0 -0
  166. data/spec/rails-app/db/migrate/20130419164907_devise_create_users.rb +0 -46
  167. data/spec/rails-app/db/migrate/20130419164936_devise_authy_add_to_users.rb +0 -18
  168. data/spec/rails-app/db/schema.rb +0 -41
  169. data/spec/rails-app/db/seeds.rb +0 -7
  170. data/spec/rails-app/lib/assets/.gitkeep +0 -0
  171. data/spec/rails-app/lib/tasks/.gitkeep +0 -0
  172. data/spec/rails-app/public/404.html +0 -26
  173. data/spec/rails-app/public/422.html +0 -26
  174. data/spec/rails-app/public/500.html +0 -25
  175. data/spec/rails-app/public/favicon.ico +0 -0
  176. data/spec/rails-app/public/robots.txt +0 -5
  177. data/spec/rails-app/script/rails +0 -6
  178. data/spec/routing/routes_spec.rb +0 -31
  179. data/spec/spec_helper.rb +0 -29
  180. data/spec/support/helpers.rb +0 -78
@@ -1,19 +1,31 @@
1
1
  class Devise::DeviseAuthyController < DeviseController
2
- prepend_before_filter :find_resource, :only => [
2
+ prepend_before_action :find_resource, :only => [
3
3
  :request_phone_call, :request_sms
4
4
  ]
5
- prepend_before_filter :find_resource_and_require_password_checked, :only => [
6
- :GET_verify_authy, :POST_verify_authy
5
+ prepend_before_action :find_resource_and_require_password_checked, :only => [
6
+ :GET_verify_authy, :POST_verify_authy, :GET_authy_onetouch_status
7
7
  ]
8
- prepend_before_filter :authenticate_scope!, :only => [
9
- :GET_enable_authy, :POST_enable_authy,
10
- :GET_verify_authy_installation, :POST_verify_authy_installation,
11
- :POST_disable_authy
8
+
9
+ prepend_before_action :check_resource_has_authy_id, :only => [
10
+ :GET_verify_authy_installation, :POST_verify_authy_installation
11
+ ]
12
+
13
+ prepend_before_action :check_resource_not_authy_enabled, :only => [
14
+ :GET_verify_authy_installation, :POST_verify_authy_installation
15
+ ]
16
+
17
+ prepend_before_action :authenticate_scope!, :only => [
18
+ :GET_enable_authy, :POST_enable_authy, :GET_verify_authy_installation,
19
+ :POST_verify_authy_installation, :POST_disable_authy
12
20
  ]
21
+
13
22
  include Devise::Controllers::Helpers
14
23
 
15
24
  def GET_verify_authy
16
- @authy_id = @resource.authy_id
25
+ if resource_class.authy_enable_onetouch
26
+ approval_request = send_one_touch_request(@resource.authy_id)['approval_request']
27
+ @onetouch_uuid = approval_request['uuid'] if approval_request.present?
28
+ end
17
29
  render :verify_authy
18
30
  end
19
31
 
@@ -26,17 +38,9 @@ class Devise::DeviseAuthyController < DeviseController
26
38
  })
27
39
 
28
40
  if token.ok?
29
- @resource.update_attribute(:last_sign_in_with_authy, DateTime.now)
30
-
31
- session["#{resource_name}_authy_token_checked"] = true
32
-
33
- remember_device if params[:remember_device].to_i == 1
34
- if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
35
- @resource.remember_me = true
36
- end
37
- sign_in(resource_name, @resource)
38
-
39
- set_flash_message(:notice, :signed_in) if is_navigational_format?
41
+ remember_device(@resource.id) if params[:remember_device].to_i == 1
42
+ remember_user
43
+ record_authy_authentication
40
44
  respond_with resource, :location => after_sign_in_path_for(@resource)
41
45
  else
42
46
  handle_invalid_token :verify_authy, :invalid_token
@@ -63,13 +67,11 @@ class Devise::DeviseAuthyController < DeviseController
63
67
  if @authy_user.ok?
64
68
  resource.authy_id = @authy_user.id
65
69
  if resource.save
66
- set_flash_message(:notice, :enabled)
70
+ redirect_to [resource_name, :verify_authy_installation] and return
67
71
  else
68
72
  set_flash_message(:error, :not_enabled)
69
73
  redirect_to after_authy_enabled_path_for(resource) and return
70
74
  end
71
-
72
- redirect_to [resource_name, :verify_authy_installation]
73
75
  else
74
76
  set_flash_message(:error, :not_enabled)
75
77
  render :enable_authy
@@ -78,21 +80,39 @@ class Devise::DeviseAuthyController < DeviseController
78
80
 
79
81
  # Disable 2FA
80
82
  def POST_disable_authy
81
- response = Authy::API.delete_user(:id => resource.authy_id)
82
-
83
- if response.ok?
84
- resource.update_attribute(:authy_enabled, false)
85
- resource.update_attribute(:authy_id, nil)
86
-
83
+ authy_id = resource.authy_id
84
+ resource.assign_attributes(:authy_enabled => false, :authy_id => nil)
85
+ resource.save(:validate => false)
86
+
87
+ other_resource = resource.class.find_by(:authy_id => authy_id)
88
+ if other_resource
89
+ # If another resource has the same authy_id, do not delete the user from
90
+ # the API.
91
+ forget_device
87
92
  set_flash_message(:notice, :disabled)
88
93
  else
89
- set_flash_message(:error, :not_disabled)
94
+ response = Authy::API.delete_user(:id => authy_id)
95
+ if response.ok?
96
+ forget_device
97
+ set_flash_message(:notice, :disabled)
98
+ else
99
+ # If deleting the user from the API fails, set everything back to what
100
+ # it was before.
101
+ # I'm not sure this is a good idea, but it was existing behaviour.
102
+ # Could be changed in a major version bump.
103
+ resource.assign_attributes(:authy_enabled => true, :authy_id => authy_id)
104
+ resource.save(:validate => false)
105
+ set_flash_message(:error, :not_disabled)
106
+ end
90
107
  end
91
-
92
108
  redirect_to after_authy_disabled_path_for(resource)
93
109
  end
94
110
 
95
111
  def GET_verify_authy_installation
112
+ if resource_class.authy_enable_qr_code
113
+ response = Authy::API.request_qr_code(id: resource.authy_id)
114
+ @authy_qr_code = response.qr_code
115
+ end
96
116
  render :verify_authy_installation
97
117
  end
98
118
 
@@ -106,13 +126,37 @@ class Devise::DeviseAuthyController < DeviseController
106
126
  self.resource.authy_enabled = token.ok?
107
127
 
108
128
  if token.ok? && self.resource.save
129
+ remember_device(@resource.id) if params[:remember_device].to_i == 1
130
+ record_authy_authentication
109
131
  set_flash_message(:notice, :enabled)
110
132
  redirect_to after_authy_verified_path_for(resource)
111
133
  else
134
+ if resource_class.authy_enable_qr_code
135
+ response = Authy::API.request_qr_code(id: resource.authy_id)
136
+ @authy_qr_code = response.qr_code
137
+ end
112
138
  handle_invalid_token :verify_authy_installation, :not_enabled
113
139
  end
114
140
  end
115
141
 
142
+ def GET_authy_onetouch_status
143
+ response = Authy::OneTouch.approval_request_status(:uuid => params[:onetouch_uuid])
144
+ status = response.dig('approval_request', 'status')
145
+ case status
146
+ when 'pending'
147
+ head 202
148
+ when 'approved'
149
+ remember_device(@resource.id) if params[:remember_device].to_i == 1
150
+ remember_user
151
+ record_authy_authentication
152
+ render json: { redirect: after_sign_in_path_for(@resource) }
153
+ when 'denied'
154
+ head :unauthorized
155
+ else
156
+ head :internal_server_error
157
+ end
158
+ end
159
+
116
160
  def request_phone_call
117
161
  unless @resource
118
162
  render :json => { :sent => false, :message => "User couldn't be found." }
@@ -157,6 +201,16 @@ class Devise::DeviseAuthyController < DeviseController
157
201
  end
158
202
  end
159
203
 
204
+ def check_resource_has_authy_id
205
+ redirect_to [resource_name, :enable_authy] if !resource.authy_id
206
+ end
207
+
208
+ def check_resource_not_authy_enabled
209
+ if resource.authy_id && resource.authy_enabled
210
+ redirect_to after_authy_verified_path_for(resource)
211
+ end
212
+ end
213
+
160
214
  protected
161
215
 
162
216
  def after_authy_enabled_path_for(resource)
@@ -187,4 +241,10 @@ class Devise::DeviseAuthyController < DeviseController
187
241
  def after_account_is_locked
188
242
  sign_out_and_redirect @resource
189
243
  end
244
+
245
+ def remember_user
246
+ if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
247
+ @resource.remember_me = true
248
+ end
249
+ end
190
250
  end
@@ -1,4 +1,22 @@
1
1
  class DeviseAuthy::PasswordsController < Devise::PasswordsController
2
+ ##
3
+ # In the passwords controller a user can update their password using a
4
+ # recovery token. If `Devise.sign_in_after_reset_password` is `true` then the
5
+ # user is signed in immediately with the
6
+ # `Devise::Controllers::SignInOut#sign_in` method. However, if the user has
7
+ # 2FA enabled they should enter their second factor before they are signed in.
8
+ #
9
+ # This method overrides `Devise::Controllers::SignInOut#sign_in` but only
10
+ # within the `Devise::PasswordsController`. If the user needs to verify 2FA
11
+ # then `sign_in` returns `true`. This short circuits the method before it can
12
+ # call `warden.set_user` and log the user in.
13
+ #
14
+ # The user is redirected to `after_resetting_password_path_for(user)` at which
15
+ # point, since the user is not logged in, redirects again to sign in.
16
+ #
17
+ # This doesn't retain the expected behaviour of
18
+ # `Devise.sign_in_after_reset_password`, but is forgivable because this
19
+ # shouldn't be an avenue to bypass 2FA.
2
20
  def sign_in(resource_or_scope, *args)
3
21
  resource = args.last || resource_or_scope
4
22
 
@@ -1,7 +1,7 @@
1
- <h2><%= I18n.t('authy_register_title', {:scope => 'devise'}) %></h2>
1
+ <h2><%= I18n.t('authy_register_title', scope: 'devise') %></h2>
2
2
 
3
3
  <%= enable_authy_form do %>
4
4
  <%= text_field_tag :country_code, '', :autocomplete => :off, :placeholder => I18n.t('devise.country'), :id => "authy-countries"%>
5
5
  <%= text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => I18n.t('devise.cellphone'), :id => "authy-cellphone"%>
6
- <p><%= submit_tag I18n.t('enable_authy', {:scope => 'devise'}) %></p>
6
+ <p><%= submit_tag I18n.t('enable_authy', scope: 'devise') %></p>
7
7
  <% end %>
@@ -1,5 +1,5 @@
1
- %h2= I18n.t('authy_register_title', {:scope => 'devise'})
1
+ %h2= I18n.t('authy_register_title', scope: 'devise')
2
2
  = enable_authy_form do
3
3
  = text_field_tag :country_code, '', :autocomplete => :off, :placeholder => I18n.t('devise.country'), :id => "authy-countries"
4
4
  = text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => I18n.t('devise.cellphone'), :id => "authy-cellphone"
5
- %p= submit_tag I18n.t('enable_authy', {:scope => 'devise'})
5
+ %p= submit_tag I18n.t('enable_authy', scope: 'devise')
@@ -1,14 +1,14 @@
1
1
  <h2>
2
- <%= I18n.t('authy_register_title', {:scope => 'devise'}) %>
2
+ <%= I18n.t('submit_token_title', scope: 'devise') %>
3
3
  </h2>
4
4
 
5
5
  <%= verify_authy_form do %>
6
- <legend><%= I18n.t('submit_token_title', {:scope => 'devise'}) %></legend>
7
- <%= label_tag :token %>
8
- <%= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token' %>
6
+ <legend><%= I18n.t('submit_token_title', scope: 'devise') %></legend>
7
+ <%= label_tag 'authy-token' %>
8
+ <%= text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token' %>
9
9
  <label>
10
10
  <%= check_box_tag :remember_device %>
11
- <span><%= I18n.t('remember_device', {:scope => 'devise'}) %></span>
11
+ <span><%= I18n.t('remember_device', scope: 'devise') %></span>
12
12
  </label>
13
13
 
14
14
  <!-- Help tooltip -->
@@ -17,5 +17,22 @@
17
17
  <!-- <%= link_to '?', '#', :id => 'authy-help' %> -->
18
18
 
19
19
  <%= authy_request_sms_link %>
20
- <%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
20
+ <%= submit_tag I18n.t('submit_token', scope: 'devise'), :class => 'btn' %>
21
+ <% end %>
22
+
23
+ <% if @onetouch_uuid %>
24
+ <script>
25
+ (function(){
26
+ var onetouchInterval = setInterval(function(){
27
+ var onetouchRequest = new XMLHttpRequest();
28
+ var rememberDevice = document.getElementById("remember_device").checked ? '1' : '0';
29
+ onetouchRequest.addEventListener("load", function(){
30
+ if(this.status != 202) clearInterval(onetouchInterval);
31
+ if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
32
+ });
33
+ onetouchRequest.open("GET", "<%= polymorphic_path [resource_name, :authy_onetouch_status] %>?remember_device="+rememberDevice+"&onetouch_uuid=<%= @onetouch_uuid %>");
34
+ onetouchRequest.send();
35
+ }, 3000);
36
+ })();
37
+ </script>
21
38
  <% end %>
@@ -1,13 +1,13 @@
1
- %h2= I18n.t('authy_register_title', {:scope => 'devise'})
1
+ %h2= I18n.t('authy_register_title', scope: 'devise')
2
2
 
3
3
  = verify_authy_form do
4
- %legend= I18n.t('submit_token_title', {:scope => 'devise'})
4
+ %legend= I18n.t('submit_token_title', scope: 'devise')
5
5
  = hidden_field_tag :"#{resource_name}_id", @resource.id
6
- = label_tag :token
7
- = text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token'
6
+ = label_tag 'authy-token'
7
+ = text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token'
8
8
  %label
9
9
  = check_box_tag :remember_device
10
- %span= I18n.t('remember_device', {:scope => 'devise'})
10
+ %span= I18n.t('remember_device', scope: 'devise')
11
11
 
12
12
  / Help Tooltip
13
13
  / You need to configure a help message.
@@ -15,4 +15,19 @@
15
15
  / = link_to '?', '#', :id => 'authy-help', :'data-message' => 'a message'
16
16
 
17
17
  = authy_request_sms_link
18
- = submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn'
18
+ = submit_tag I18n.t('submit_token', scope: 'devise'), :class => 'btn'
19
+
20
+ - if @onetouch_uuid
21
+ :javascript
22
+ (function(){
23
+ var onetouchInterval = setInterval(function(){
24
+ var onetouchRequest = new XMLHttpRequest();
25
+ var rememberDevice = document.getElementById("remember_device").checked ? '1' : '0';
26
+ onetouchRequest.addEventListener("load", function(){
27
+ if(this.status != 202) clearInterval(onetouchInterval);
28
+ if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
29
+ });
30
+ onetouchRequest.open("GET", "#{polymorphic_path [resource_name, :authy_onetouch_status]}?remember_device="+rememberDevice+"&onetouch_uuid=#{@onetouch_uuid}");
31
+ onetouchRequest.send();
32
+ }, 3000);
33
+ })();
@@ -1,10 +1,18 @@
1
- <h2><%= I18n.t('authy_verify_installation_title', {:scope => 'devise'}) %></h2>
1
+ <h2><%= I18n.t('authy_verify_installation_title', scope: 'devise') %></h2>
2
+
3
+ <% if @authy_qr_code %>
4
+ <%= image_tag @authy_qr_code, :size => '256x256', :alt => I18n.t('authy_qr_code_alt', scope: 'devise') %>
5
+ <p><%= I18n.t('authy_qr_code_instructions', scope: 'devise') %></p>
6
+ <% end %>
2
7
 
3
8
  <%= verify_authy_installation_form do %>
4
- <legend><%= I18n.t('submit_token_title', {:scope => 'devise'}) %></legend>
9
+ <legend><%= I18n.t('submit_token_title', scope: 'devise') %></legend>
5
10
  <%= label_tag :token %>
6
- <%= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token' %>
11
+ <%= text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token' %>
12
+ <label>
13
+ <%= check_box_tag :remember_device %>
14
+ <span><%= I18n.t('remember_device', scope: 'devise') %></span>
15
+ </label>
7
16
  <%= authy_request_sms_link %>
8
- <%= submit_tag I18n.t('enable_my_account', {:scope => 'devise'}), :class => 'btn' %>
9
- <% end %>
10
-
17
+ <%= submit_tag I18n.t('enable_my_account', scope: 'devise'), :class => 'btn' %>
18
+ <% end %>
@@ -1,8 +1,16 @@
1
- %h2= I18n.t('authy_verify_installation_title', {:scope => 'devise'})
1
+ %h2= I18n.t('authy_verify_installation_title', scope: 'devise')
2
+
3
+ - if @authy_qr_code
4
+ = image_tag @authy_qr_code, :size => '256x256', :alt => I18n.t('authy_qr_code_alt', scope: 'devise')
5
+ %p= I18n.t('authy_qr_code_instructions', scope: 'devise')
6
+
2
7
  = verify_authy_installation_form do
3
- %legend= I18n.t('submit_token_title', {:scope => 'devise'})
8
+ %legend= I18n.t('submit_token_title', scope: 'devise')
4
9
  = label_tag :token
5
- = text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token'
10
+ = text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token'
11
+ %label
12
+ = check_box_tag :remember_device
13
+ %span= I18n.t('remember_device', scope: 'devise')
6
14
  = authy_request_sms_link
7
- = submit_tag I18n.t('enable_my_account', {:scope => 'devise'}), :class => 'btn'
15
+ = submit_tag I18n.t('enable_my_account', scope: 'devise'), :class => 'btn'
8
16
 
@@ -1,7 +1,7 @@
1
1
  en:
2
2
  devise:
3
- submit_token: "Check Token"
4
- submit_token_title: "Please enter your Authy token:"
3
+ submit_token: 'Check Token'
4
+ submit_token_title: 'Please enter your Authy token:'
5
5
  authy_register_title: 'Enable Two factor authentication'
6
6
  enable_authy: 'Enable'
7
7
  cellphone: 'Enter your cellphone'
@@ -9,10 +9,14 @@ en:
9
9
  request_sms: 'Request SMS'
10
10
  request_phone_call: 'Request phone call'
11
11
  remember_device: 'Remember Device'
12
+ request_to_login: 'Request to Login'
12
13
 
13
- authy_verify_installation_title: "Verify your account"
14
+ authy_verify_installation_title: 'Verify your account'
14
15
  enable_my_account: 'Enable my account'
15
16
 
17
+ authy_qr_code_alt: 'QR code for scanning with your authenticator app.'
18
+ authy_qr_code_instructions: 'Scan this QR code with your authenticator application and enter the code below.'
19
+
16
20
  devise_authy:
17
21
  user:
18
22
  enabled: 'Two factor authentication was enabled'
@@ -20,5 +24,5 @@ en:
20
24
  disabled: 'Two factor authentication was disabled'
21
25
  not_disabled: 'Something went wrong while disabling two factor authentication'
22
26
  signed_in: 'Signed in with Authy successfully.'
23
- already_enabled: "Two factor authentication is already enabled."
27
+ already_enabled: 'Two factor authentication is already enabled.'
24
28
  invalid_token: 'The entered token is invalid'
data/config.ru ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize! :all
9
+ run Combustion::Application