devise-authy 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +2 -2
- data/README.md +16 -1
- data/VERSION +1 -1
- data/app/controllers/devise/devise_authy_controller.rb +21 -8
- data/app/views/devise/verify_authy.html.erb +16 -0
- data/app/views/devise/verify_authy.html.haml +14 -0
- data/authy-devise-demo/Gemfile.lock +4 -4
- data/authy-devise-demo/app/views/devise/devise_authy/verify_authy.html.erb +16 -0
- data/authy-devise-demo/config/initializers/devise.rb +3 -0
- data/devise-authy.gemspec +10 -10
- data/lib/devise-authy.rb +2 -1
- data/lib/devise-authy/controllers/helpers.rb +11 -0
- data/lib/devise-authy/models/authy_authenticatable.rb +1 -1
- data/lib/devise-authy/routes.rb +1 -0
- data/lib/generators/devise_authy/install_generator.rb +4 -1
- data/spec/controllers/devise_authy_controller_spec.rb +84 -5
- data/spec/rails-app/Gemfile.lock +72 -71
- data/spec/rails-app/app/views/devise/devise_authy/verify_authy.html.erb +16 -0
- data/spec/rails-app/config/initializers/devise.rb +11 -0
- data/spec/routing/routes_spec.rb +4 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b4a21e73c3efd8c4368a9685a1034a6dd43028949d6427309ee0ebd646d5c147
|
4
|
+
data.tar.gz: a3eaac986e7eb6620333bd9a6ea21d5aaa4ec58983a92cd1bc3650f2e02c3fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 100a286438cc5befc4c02249aff14c68fde76ad20a05f8ec740241e54b92c797abce24d3aacb449fca1c2de31c5320d4d5914b47be8de39b5a23cab5520b836b
|
7
|
+
data.tar.gz: 8c958b9a2d7b852917df7a130f25b62325783f5e31e2a800a7755428dddf2a3ec573d82d89e164011ac3f99e3a1b1fa76a701e66e8d9f94a1dd5bf4ee77bfb31
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -53,7 +53,8 @@ Change the default routes to point to something sane like:
|
|
53
53
|
devise_for :users, :path_names => {
|
54
54
|
:verify_authy => "/verify-token",
|
55
55
|
:enable_authy => "/enable-two-factor",
|
56
|
-
:verify_authy_installation => "/verify-installation"
|
56
|
+
:verify_authy_installation => "/verify-installation",
|
57
|
+
:authy_onetouch_status => "/onetouch-status"
|
57
58
|
}
|
58
59
|
```
|
59
60
|
|
@@ -136,6 +137,14 @@ session["#{resource_name}_authy_token_checked"]
|
|
136
137
|
session["user_authy_token_checked"]
|
137
138
|
```
|
138
139
|
|
140
|
+
## OneTouch support
|
141
|
+
|
142
|
+
To enable the OneTouch feature, you need to modify the Devise config file `config/initializers/devise.rb` and add configuration:
|
143
|
+
|
144
|
+
```
|
145
|
+
config.authy_enable_onetouch = true
|
146
|
+
```
|
147
|
+
|
139
148
|
|
140
149
|
## Running Tests
|
141
150
|
|
@@ -151,6 +160,12 @@ Now on the project root run the following commands:
|
|
151
160
|
$ bundle exec rspec spec/
|
152
161
|
```
|
153
162
|
|
163
|
+
## Backporting to Rails 3
|
164
|
+
|
165
|
+
While we are not currently supporting Rails 3, there's an active fork that maintains the backwards compatibility.
|
166
|
+
|
167
|
+
https://github.com/gcosta/authy-devise
|
168
|
+
|
154
169
|
## Copyright
|
155
170
|
|
156
171
|
Copyright (c) 2012-2020 Authy Inc. See LICENSE.txt for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.2
|
@@ -3,7 +3,7 @@ class Devise::DeviseAuthyController < DeviseController
|
|
3
3
|
:request_phone_call, :request_sms
|
4
4
|
]
|
5
5
|
prepend_before_action :find_resource_and_require_password_checked, :only => [
|
6
|
-
:GET_verify_authy, :POST_verify_authy
|
6
|
+
:GET_verify_authy, :POST_verify_authy, :GET_authy_onetouch_status
|
7
7
|
]
|
8
8
|
prepend_before_action :authenticate_scope!, :only => [
|
9
9
|
:GET_enable_authy, :POST_enable_authy,
|
@@ -14,6 +14,10 @@ class Devise::DeviseAuthyController < DeviseController
|
|
14
14
|
|
15
15
|
def GET_verify_authy
|
16
16
|
@authy_id = @resource.authy_id
|
17
|
+
if resource_class.authy_enable_onetouch
|
18
|
+
approval_request = send_one_touch_request['approval_request']
|
19
|
+
@onetouch_uuid = approval_request['uuid'] if approval_request.present?
|
20
|
+
end
|
17
21
|
render :verify_authy
|
18
22
|
end
|
19
23
|
|
@@ -26,17 +30,11 @@ class Devise::DeviseAuthyController < DeviseController
|
|
26
30
|
})
|
27
31
|
|
28
32
|
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
33
|
remember_device if params[:remember_device].to_i == 1
|
34
34
|
if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
|
35
35
|
@resource.remember_me = true
|
36
36
|
end
|
37
|
-
|
38
|
-
|
39
|
-
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
37
|
+
record_authy_authentication
|
40
38
|
respond_with resource, :location => after_sign_in_path_for(@resource)
|
41
39
|
else
|
42
40
|
handle_invalid_token :verify_authy, :invalid_token
|
@@ -112,6 +110,21 @@ class Devise::DeviseAuthyController < DeviseController
|
|
112
110
|
handle_invalid_token :verify_authy_installation, :not_enabled
|
113
111
|
end
|
114
112
|
end
|
113
|
+
|
114
|
+
def GET_authy_onetouch_status
|
115
|
+
status = Authy::API.get_request("onetouch/json/approval_requests/#{params[:onetouch_uuid]}")['approval_request']['status']
|
116
|
+
case status
|
117
|
+
when 'pending'
|
118
|
+
head 202
|
119
|
+
when 'approved'
|
120
|
+
record_authy_authentication
|
121
|
+
render json: { redirect: after_sign_in_path_for(@resource) }
|
122
|
+
when 'denied'
|
123
|
+
head :unauthorized
|
124
|
+
else
|
125
|
+
head :error
|
126
|
+
end
|
127
|
+
end
|
115
128
|
|
116
129
|
def request_phone_call
|
117
130
|
unless @resource
|
@@ -19,3 +19,19 @@
|
|
19
19
|
<%= authy_request_sms_link %>
|
20
20
|
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
21
21
|
<% end %>
|
22
|
+
|
23
|
+
<% if @onetouch_uuid %>
|
24
|
+
<script>
|
25
|
+
(function(){
|
26
|
+
var onetouchInterval = setInterval(function(){
|
27
|
+
var onetouchRequest = new XMLHttpRequest();
|
28
|
+
onetouchRequest.addEventListener("load", function(){
|
29
|
+
if(this.status != 202) clearInterval(onetouchInterval);
|
30
|
+
if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
|
31
|
+
});
|
32
|
+
onetouchRequest.open("GET", "<%= polymorphic_path [resource_name, :authy_onetouch_status] %>?onetouch_uuid=<%= @onetouch_uuid %>");
|
33
|
+
onetouchRequest.send();
|
34
|
+
}, 3000);
|
35
|
+
})();
|
36
|
+
</script>
|
37
|
+
<% end %>
|
@@ -16,3 +16,17 @@
|
|
16
16
|
|
17
17
|
= authy_request_sms_link
|
18
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
|
+
onetouchRequest.addEventListener("load", function(){
|
26
|
+
if(this.status != 202) clearInterval(onetouchInterval);
|
27
|
+
if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
|
28
|
+
});
|
29
|
+
onetouchRequest.open("GET", "<%= polymorphic_path [resource_name, :authy_onetouch_status] %>?onetouch_uuid=<%= @onetouch_uuid %>");
|
30
|
+
onetouchRequest.send();
|
31
|
+
}, 3000);
|
32
|
+
})();
|
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
devise-authy (1.8.
|
5
|
-
authy
|
4
|
+
devise-authy (1.8.1)
|
5
|
+
authy (>= 2.4.2)
|
6
6
|
devise (>= 3.0.0)
|
7
7
|
|
8
8
|
GEM
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
execjs (2.7.0)
|
77
77
|
globalid (0.3.7)
|
78
78
|
activesupport (>= 4.1.0)
|
79
|
-
httpclient (2.8.
|
79
|
+
httpclient (2.8.3)
|
80
80
|
i18n (0.7.0)
|
81
81
|
jbuilder (2.6.0)
|
82
82
|
activesupport (>= 3.0.0, < 5.1)
|
@@ -191,4 +191,4 @@ DEPENDENCIES
|
|
191
191
|
web-console (~> 2.0)
|
192
192
|
|
193
193
|
BUNDLED WITH
|
194
|
-
1.
|
194
|
+
1.16.0
|
@@ -20,3 +20,19 @@
|
|
20
20
|
<%= authy_request_phone_call_link %>
|
21
21
|
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
22
22
|
<% end %>
|
23
|
+
|
24
|
+
<% if @onetouch_uuid %>
|
25
|
+
<script>
|
26
|
+
(function(){
|
27
|
+
var onetouchInterval = setInterval(function(){
|
28
|
+
var onetouchRequest = new XMLHttpRequest();
|
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] %>?onetouch_uuid=<%= @onetouch_uuid %>");
|
34
|
+
onetouchRequest.send();
|
35
|
+
}, 3000);
|
36
|
+
})();
|
37
|
+
</script>
|
38
|
+
<% end %>
|
@@ -5,6 +5,9 @@ Devise.setup do |config|
|
|
5
5
|
# ==> Devise Authy Authentication Extension
|
6
6
|
# How long should the user's device be remembered for.
|
7
7
|
# config.authy_remember_device = 1.month
|
8
|
+
#
|
9
|
+
# Should Authy OneTouch be enabled?
|
10
|
+
config.authy_enable_onetouch = true
|
8
11
|
|
9
12
|
# ==> Mailer Configuration
|
10
13
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
data/devise-authy.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: devise-authy 1.8.
|
5
|
+
# stub: devise-authy 1.8.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "devise-authy".freeze
|
9
|
-
s.version = "1.8.
|
9
|
+
s.version = "1.8.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Authy Inc.".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2017-12-22"
|
15
15
|
s.description = "Authy plugin for Devise".freeze
|
16
16
|
s.email = "support@authy.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -200,7 +200,7 @@ Gem::Specification.new do |s|
|
|
200
200
|
]
|
201
201
|
s.homepage = "https://github.com/authy/authy-devise".freeze
|
202
202
|
s.licenses = ["MIT".freeze]
|
203
|
-
s.rubygems_version = "2.
|
203
|
+
s.rubygems_version = "2.7.3".freeze
|
204
204
|
s.summary = "Authy plugin for Devise".freeze
|
205
205
|
|
206
206
|
if s.respond_to? :specification_version then
|
@@ -208,9 +208,9 @@ Gem::Specification.new do |s|
|
|
208
208
|
|
209
209
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
210
210
|
s.add_runtime_dependency(%q<devise>.freeze, [">= 3.0.0"])
|
211
|
-
s.add_runtime_dependency(%q<authy>.freeze, [">=
|
211
|
+
s.add_runtime_dependency(%q<authy>.freeze, [">= 2.7.2"])
|
212
212
|
s.add_development_dependency(%q<rspec>.freeze, ["> 3.0.0"])
|
213
|
-
s.add_development_dependency(%q<yard>.freeze, ["
|
213
|
+
s.add_development_dependency(%q<yard>.freeze, ["~> 0.9.11"])
|
214
214
|
s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
|
215
215
|
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
216
216
|
s.add_development_dependency(%q<jeweler>.freeze, [">= 2.0.1"])
|
@@ -218,9 +218,9 @@ Gem::Specification.new do |s|
|
|
218
218
|
s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
|
219
219
|
else
|
220
220
|
s.add_dependency(%q<devise>.freeze, [">= 3.0.0"])
|
221
|
-
s.add_dependency(%q<authy>.freeze, [">=
|
221
|
+
s.add_dependency(%q<authy>.freeze, [">= 2.7.2"])
|
222
222
|
s.add_dependency(%q<rspec>.freeze, ["> 3.0.0"])
|
223
|
-
s.add_dependency(%q<yard>.freeze, ["
|
223
|
+
s.add_dependency(%q<yard>.freeze, ["~> 0.9.11"])
|
224
224
|
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
|
225
225
|
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
226
226
|
s.add_dependency(%q<jeweler>.freeze, [">= 2.0.1"])
|
@@ -229,9 +229,9 @@ Gem::Specification.new do |s|
|
|
229
229
|
end
|
230
230
|
else
|
231
231
|
s.add_dependency(%q<devise>.freeze, [">= 3.0.0"])
|
232
|
-
s.add_dependency(%q<authy>.freeze, [">=
|
232
|
+
s.add_dependency(%q<authy>.freeze, [">= 2.7.2"])
|
233
233
|
s.add_dependency(%q<rspec>.freeze, ["> 3.0.0"])
|
234
|
-
s.add_dependency(%q<yard>.freeze, ["
|
234
|
+
s.add_dependency(%q<yard>.freeze, ["~> 0.9.11"])
|
235
235
|
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
|
236
236
|
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
237
237
|
s.add_dependency(%q<jeweler>.freeze, [">= 2.0.1"])
|
data/lib/devise-authy.rb
CHANGED
@@ -70,6 +70,17 @@ module DeviseAuthy
|
|
70
70
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
71
71
|
send(:"#{scope}_verify_authy_path")
|
72
72
|
end
|
73
|
+
|
74
|
+
def send_one_touch_request
|
75
|
+
Authy::OneTouch.send_approval_request(id: @authy_id, message: 'Request to Login')
|
76
|
+
end
|
77
|
+
|
78
|
+
def record_authy_authentication
|
79
|
+
@resource.update_attribute(:last_sign_in_with_authy, DateTime.now)
|
80
|
+
session["#{resource_name}_authy_token_checked"] = true
|
81
|
+
sign_in(resource_name, @resource)
|
82
|
+
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
83
|
+
end
|
73
84
|
end
|
74
85
|
end
|
75
86
|
end
|
data/lib/devise-authy/routes.rb
CHANGED
@@ -14,6 +14,7 @@ module ActionDispatch::Routing
|
|
14
14
|
match "/#{mapping.path_names[:verify_authy_installation]}", :controller => controllers[:devise_authy], :action => :GET_verify_authy_installation, :as => :verify_authy_installation, :via => :get
|
15
15
|
match "/#{mapping.path_names[:verify_authy_installation]}", :controller => controllers[:devise_authy], :action => :POST_verify_authy_installation, :as => nil, :via => :post
|
16
16
|
|
17
|
+
match "/#{mapping.path_names[:authy_onetouch_status]}", :controller => controllers[:devise_authy], :action => :GET_authy_onetouch_status, as: :authy_onetouch_status, via: :get
|
17
18
|
|
18
19
|
match "/request-sms", :controller => controllers[:devise_authy], :action => :request_sms, :as => :request_sms, :via => :post
|
19
20
|
match "/request-phone-call", :controller => controllers[:devise_authy], :action => :request_phone_call, :as => :request_phone_call, :via => :post
|
@@ -13,7 +13,10 @@ module DeviseAuthy
|
|
13
13
|
inject_into_file "config/initializers/devise.rb", "\n" +
|
14
14
|
" # ==> Devise Authy Authentication Extension\n" +
|
15
15
|
" # How long should the user's device be remembered for.\n" +
|
16
|
-
" # config.authy_remember_device = 1.month\n\n"
|
16
|
+
" # config.authy_remember_device = 1.month\n\n" +
|
17
|
+
" # Should Authy OneTouch be enabled?\n" +
|
18
|
+
" # config.authy_enable_onetouch = false\n\n", :after => "Devise.setup do |config|\n"
|
19
|
+
|
17
20
|
end
|
18
21
|
|
19
22
|
def add_initializer
|
@@ -9,11 +9,34 @@ describe Devise::DeviseAuthyController, type: :controller do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "GET #verify_authy" do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
describe "when the first step of authentication is complete" do
|
13
|
+
before do
|
14
|
+
request.session["user_id"] = @user.id
|
15
|
+
request.session["user_password_checked"] = true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "Should render the second step of authentication" do
|
19
|
+
get :GET_verify_authy
|
20
|
+
expect(response).to render_template('verify_authy')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not make a OneTouch request" do
|
24
|
+
expect(Authy::OneTouch).not_to receive(:send_approval_request)
|
25
|
+
get :GET_verify_authy
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when OneTouch is enabled" do
|
29
|
+
before do
|
30
|
+
allow(User).to receive(:authy_enable_onetouch).and_return(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should make a OneTouch request" do
|
34
|
+
expect(Authy::OneTouch).to receive(:send_approval_request)
|
35
|
+
.with(id: @user.authy_id, message: 'Request to Login')
|
36
|
+
.and_return('approval_request' => { 'uuid' => 'uuid' }).once
|
37
|
+
get :GET_verify_authy
|
38
|
+
end
|
39
|
+
end
|
17
40
|
end
|
18
41
|
|
19
42
|
it "Should no render the second step of authentication if first step is incomplete" do
|
@@ -26,6 +49,11 @@ describe Devise::DeviseAuthyController, type: :controller do
|
|
26
49
|
get :GET_verify_authy
|
27
50
|
expect(response).to redirect_to(root_url)
|
28
51
|
end
|
52
|
+
|
53
|
+
it "should not make a OneTouch request" do
|
54
|
+
expect(Authy::OneTouch).not_to receive(:send_approval_request)
|
55
|
+
get :GET_verify_authy
|
56
|
+
end
|
29
57
|
end
|
30
58
|
|
31
59
|
describe "POST #verify_authy" do
|
@@ -269,4 +297,55 @@ describe Devise::DeviseAuthyController, type: :controller do
|
|
269
297
|
expect(body['message']).to eq("User couldn't be found.")
|
270
298
|
end
|
271
299
|
end
|
300
|
+
|
301
|
+
describe "GET #authy_onetouch_status" do
|
302
|
+
# OneTouch stubbed due to test API key not having OneTouch enabled
|
303
|
+
before do
|
304
|
+
allow(Authy::OneTouch).to receive(:send_approval_request).with(id: @user.authy_id) { { 'approval_request' => { 'uuid' => SecureRandom.uuid } } }
|
305
|
+
@uuid = Authy::OneTouch.send_approval_request(id: @user.authy_id)['approval_request']['uuid']
|
306
|
+
end
|
307
|
+
|
308
|
+
it "Should return a 202 status code when pending" do
|
309
|
+
allow(Authy::API).to receive(:get_request).with(/onetouch\/json\/approval_requests\/.+/) { { 'approval_request' => { 'status' => 'pending' } } }
|
310
|
+
request.session["user_id"] = @user.id
|
311
|
+
request.session["user_password_checked"] = true
|
312
|
+
get :GET_authy_onetouch_status, onetouch_uuid: @uuid
|
313
|
+
expect(response.code).to eq("202")
|
314
|
+
end
|
315
|
+
|
316
|
+
it "Should return a 401 status code when denied" do
|
317
|
+
allow(Authy::API).to receive(:get_request).with(/onetouch\/json\/approval_requests\/.+/) { { 'approval_request' => { 'status' => 'denied' } } }
|
318
|
+
request.session["user_id"] = @user.id
|
319
|
+
request.session["user_password_checked"] = true
|
320
|
+
get :GET_authy_onetouch_status, onetouch_uuid: @uuid
|
321
|
+
expect(response.code).to eq("401")
|
322
|
+
end
|
323
|
+
|
324
|
+
it "Should return a 200 status code when approved" do
|
325
|
+
allow(Authy::API).to receive(:get_request).with(/onetouch\/json\/approval_requests\/.+/) { { 'approval_request' => { 'status' => 'approved' } } }
|
326
|
+
request.session["user_id"] = @user.id
|
327
|
+
request.session["user_password_checked"] = true
|
328
|
+
get :GET_authy_onetouch_status, onetouch_uuid: @uuid
|
329
|
+
expect(response.code).to eq("200")
|
330
|
+
end
|
331
|
+
|
332
|
+
it "Should render a JSON object with the redirect path when approved" do
|
333
|
+
allow(Authy::API).to receive(:get_request).with(/onetouch\/json\/approval_requests\/.+/) { { 'approval_request' => { 'status' => 'approved' } } }
|
334
|
+
request.session["user_id"] = @user.id
|
335
|
+
request.session["user_password_checked"] = true
|
336
|
+
get :GET_authy_onetouch_status, onetouch_uuid: @uuid
|
337
|
+
expect(response.body).to eq({ redirect: root_path }.to_json)
|
338
|
+
end
|
339
|
+
|
340
|
+
it "Should not render the second step of authentication if first step is incomplete" do
|
341
|
+
request.session["user_id"] = @user.id
|
342
|
+
get :GET_authy_onetouch_status
|
343
|
+
expect(response).to redirect_to(root_url)
|
344
|
+
end
|
345
|
+
|
346
|
+
it "should redirect to root_url" do
|
347
|
+
get :GET_authy_onetouch_status
|
348
|
+
expect(response).to redirect_to(root_url)
|
349
|
+
end
|
350
|
+
end
|
272
351
|
end
|
data/spec/rails-app/Gemfile.lock
CHANGED
@@ -1,126 +1,127 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
devise-authy (1.8.
|
5
|
-
authy
|
4
|
+
devise-authy (1.8.2)
|
5
|
+
authy (>= 2.7.2)
|
6
6
|
devise (>= 3.0.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionmailer (4.2.
|
12
|
-
actionpack (= 4.2.
|
13
|
-
actionview (= 4.2.
|
14
|
-
activejob (= 4.2.
|
11
|
+
actionmailer (4.2.10)
|
12
|
+
actionpack (= 4.2.10)
|
13
|
+
actionview (= 4.2.10)
|
14
|
+
activejob (= 4.2.10)
|
15
15
|
mail (~> 2.5, >= 2.5.4)
|
16
16
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
17
|
-
actionpack (4.2.
|
18
|
-
actionview (= 4.2.
|
19
|
-
activesupport (= 4.2.
|
17
|
+
actionpack (4.2.10)
|
18
|
+
actionview (= 4.2.10)
|
19
|
+
activesupport (= 4.2.10)
|
20
20
|
rack (~> 1.6)
|
21
21
|
rack-test (~> 0.6.2)
|
22
22
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
23
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
-
actionview (4.2.
|
25
|
-
activesupport (= 4.2.
|
24
|
+
actionview (4.2.10)
|
25
|
+
activesupport (= 4.2.10)
|
26
26
|
builder (~> 3.1)
|
27
27
|
erubis (~> 2.7.0)
|
28
28
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.
|
30
|
-
activejob (4.2.
|
31
|
-
activesupport (= 4.2.
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
30
|
+
activejob (4.2.10)
|
31
|
+
activesupport (= 4.2.10)
|
32
32
|
globalid (>= 0.3.0)
|
33
|
-
activemodel (4.2.
|
34
|
-
activesupport (= 4.2.
|
33
|
+
activemodel (4.2.10)
|
34
|
+
activesupport (= 4.2.10)
|
35
35
|
builder (~> 3.1)
|
36
|
-
activerecord (4.2.
|
37
|
-
activemodel (= 4.2.
|
38
|
-
activesupport (= 4.2.
|
36
|
+
activerecord (4.2.10)
|
37
|
+
activemodel (= 4.2.10)
|
38
|
+
activesupport (= 4.2.10)
|
39
39
|
arel (~> 6.0)
|
40
|
-
activesupport (4.2.
|
40
|
+
activesupport (4.2.10)
|
41
41
|
i18n (~> 0.7)
|
42
|
-
json (~> 1.7, >= 1.7.7)
|
43
42
|
minitest (~> 5.1)
|
44
43
|
thread_safe (~> 0.3, >= 0.3.4)
|
45
44
|
tzinfo (~> 1.1)
|
46
|
-
addressable (2.
|
47
|
-
|
48
|
-
|
45
|
+
addressable (2.5.2)
|
46
|
+
public_suffix (>= 2.0.2, < 4.0)
|
47
|
+
arel (6.0.4)
|
48
|
+
authy (2.7.2)
|
49
49
|
httpclient (>= 2.5.3.3)
|
50
50
|
bcrypt (3.1.11)
|
51
|
-
builder (3.2.
|
52
|
-
concurrent-ruby (1.0.
|
53
|
-
|
51
|
+
builder (3.2.3)
|
52
|
+
concurrent-ruby (1.0.5)
|
53
|
+
crass (1.0.3)
|
54
|
+
devise (4.3.0)
|
54
55
|
bcrypt (~> 3.0)
|
55
56
|
orm_adapter (~> 0.1)
|
56
|
-
railties (>= 4.1.0, < 5.
|
57
|
+
railties (>= 4.1.0, < 5.2)
|
57
58
|
responders
|
58
59
|
warden (~> 1.2.3)
|
59
60
|
erubis (2.7.0)
|
60
|
-
globalid (0.
|
61
|
-
activesupport (>= 4.
|
62
|
-
httpclient (2.8.
|
63
|
-
i18n (0.
|
64
|
-
|
61
|
+
globalid (0.4.1)
|
62
|
+
activesupport (>= 4.2.0)
|
63
|
+
httpclient (2.8.3)
|
64
|
+
i18n (0.9.1)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
json (2.1.0)
|
65
67
|
launchy (2.4.3)
|
66
68
|
addressable (~> 2.3)
|
67
|
-
loofah (2.
|
69
|
+
loofah (2.1.1)
|
70
|
+
crass (~> 1.0.2)
|
68
71
|
nokogiri (>= 1.5.9)
|
69
|
-
mail (2.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
nokogiri (1.6.8)
|
77
|
-
mini_portile2 (~> 2.1.0)
|
78
|
-
pkg-config (~> 1.1.7)
|
72
|
+
mail (2.7.0)
|
73
|
+
mini_mime (>= 0.1.1)
|
74
|
+
mini_mime (1.0.0)
|
75
|
+
mini_portile2 (2.3.0)
|
76
|
+
minitest (5.10.3)
|
77
|
+
nokogiri (1.8.1)
|
78
|
+
mini_portile2 (~> 2.3.0)
|
79
79
|
orm_adapter (0.5.0)
|
80
|
-
|
81
|
-
rack (1.6.
|
80
|
+
public_suffix (3.0.1)
|
81
|
+
rack (1.6.8)
|
82
82
|
rack-test (0.6.3)
|
83
83
|
rack (>= 1.0)
|
84
|
-
rails (4.2.
|
85
|
-
actionmailer (= 4.2.
|
86
|
-
actionpack (= 4.2.
|
87
|
-
actionview (= 4.2.
|
88
|
-
activejob (= 4.2.
|
89
|
-
activemodel (= 4.2.
|
90
|
-
activerecord (= 4.2.
|
91
|
-
activesupport (= 4.2.
|
84
|
+
rails (4.2.10)
|
85
|
+
actionmailer (= 4.2.10)
|
86
|
+
actionpack (= 4.2.10)
|
87
|
+
actionview (= 4.2.10)
|
88
|
+
activejob (= 4.2.10)
|
89
|
+
activemodel (= 4.2.10)
|
90
|
+
activerecord (= 4.2.10)
|
91
|
+
activesupport (= 4.2.10)
|
92
92
|
bundler (>= 1.3.0, < 2.0)
|
93
|
-
railties (= 4.2.
|
93
|
+
railties (= 4.2.10)
|
94
94
|
sprockets-rails
|
95
95
|
rails-deprecated_sanitizer (1.0.3)
|
96
96
|
activesupport (>= 4.2.0.alpha)
|
97
|
-
rails-dom-testing (1.0.
|
97
|
+
rails-dom-testing (1.0.8)
|
98
98
|
activesupport (>= 4.2.0.beta, < 5.0)
|
99
|
-
nokogiri (~> 1.6
|
99
|
+
nokogiri (~> 1.6)
|
100
100
|
rails-deprecated_sanitizer (>= 1.0.1)
|
101
101
|
rails-html-sanitizer (1.0.3)
|
102
102
|
loofah (~> 2.0)
|
103
|
-
railties (4.2.
|
104
|
-
actionpack (= 4.2.
|
105
|
-
activesupport (= 4.2.
|
103
|
+
railties (4.2.10)
|
104
|
+
actionpack (= 4.2.10)
|
105
|
+
activesupport (= 4.2.10)
|
106
106
|
rake (>= 0.8.7)
|
107
107
|
thor (>= 0.18.1, < 2.0)
|
108
|
-
rake (
|
109
|
-
responders (2.
|
110
|
-
|
111
|
-
|
108
|
+
rake (12.3.0)
|
109
|
+
responders (2.4.0)
|
110
|
+
actionpack (>= 4.2.0, < 5.3)
|
111
|
+
railties (>= 4.2.0, < 5.3)
|
112
|
+
sprockets (3.7.1)
|
112
113
|
concurrent-ruby (~> 1.0)
|
113
114
|
rack (> 1, < 3)
|
114
|
-
sprockets-rails (3.2.
|
115
|
+
sprockets-rails (3.2.1)
|
115
116
|
actionpack (>= 4.0)
|
116
117
|
activesupport (>= 4.0)
|
117
118
|
sprockets (>= 3.0.0)
|
118
|
-
sqlite3 (1.3.
|
119
|
-
thor (0.
|
120
|
-
thread_safe (0.3.
|
121
|
-
tzinfo (1.2.
|
119
|
+
sqlite3 (1.3.13)
|
120
|
+
thor (0.20.0)
|
121
|
+
thread_safe (0.3.6)
|
122
|
+
tzinfo (1.2.4)
|
122
123
|
thread_safe (~> 0.1)
|
123
|
-
warden (1.2.
|
124
|
+
warden (1.2.7)
|
124
125
|
rack (>= 1.0)
|
125
126
|
|
126
127
|
PLATFORMS
|
@@ -137,4 +138,4 @@ DEPENDENCIES
|
|
137
138
|
sqlite3
|
138
139
|
|
139
140
|
BUNDLED WITH
|
140
|
-
1.
|
141
|
+
1.16.0
|
@@ -19,3 +19,19 @@
|
|
19
19
|
<%= authy_request_sms_link %>
|
20
20
|
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
21
21
|
<% end %>
|
22
|
+
|
23
|
+
<% if @onetouch_uuid %>
|
24
|
+
<script>
|
25
|
+
(function(){
|
26
|
+
setInterval(function(){
|
27
|
+
var onetouchRequest = new XMLHttpRequest();
|
28
|
+
onetouchRequest.addEventListener("load", function(){
|
29
|
+
if(this.status != 202) clearInterval(onetouch_status);
|
30
|
+
if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
|
31
|
+
});
|
32
|
+
onetouchRequest.open("GET", "#{polymorphic_path [resource_name, :authy_onetouch_status]}?onetouch_uuid=#{@onetouch_uuid}");
|
33
|
+
onetouchRequest.send();
|
34
|
+
}, 3000);
|
35
|
+
})();
|
36
|
+
</script>
|
37
|
+
<% end %>
|
@@ -1,6 +1,14 @@
|
|
1
1
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
2
|
# Many of these configuration options can be set straight in your model.
|
3
3
|
Devise.setup do |config|
|
4
|
+
|
5
|
+
# ==> Devise Authy Authentication Extension
|
6
|
+
# How long should the user's device be remembered for.
|
7
|
+
# config.authy_remember_device = 1.month
|
8
|
+
|
9
|
+
# Should Authy OneTouch be enabled?
|
10
|
+
# config.authy_enable_onetouch = false
|
11
|
+
|
4
12
|
# ==> Mailer Configuration
|
5
13
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
6
14
|
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
@@ -241,5 +249,8 @@ Devise.setup do |config|
|
|
241
249
|
# ==> Devise Authy Authentication Extension
|
242
250
|
# How long should the user's device be remembered for.
|
243
251
|
# config.authy_remember_device = 1.month
|
252
|
+
#
|
253
|
+
# Should Authy OneTouch be enabled?
|
254
|
+
# config.authy_enable_onetouch = false
|
244
255
|
|
245
256
|
end
|
data/spec/routing/routes_spec.rb
CHANGED
@@ -28,4 +28,8 @@ describe "routes for devise_authy" do
|
|
28
28
|
it "routes to devise_authy#request_sms" do
|
29
29
|
expect(post('/users/request-sms')).to route_to("devise/devise_authy#request_sms")
|
30
30
|
end
|
31
|
+
|
32
|
+
it "routes to devise_authy#GET_authy_onetouch_status" do
|
33
|
+
expect(get('/users/authy_onetouch_status')).to route_to("devise/devise_authy#GET_authy_onetouch_status")
|
34
|
+
end
|
31
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-authy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Authy Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.7.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.7.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.9.11
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.9.11
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
342
|
version: '0'
|
343
343
|
requirements: []
|
344
344
|
rubyforge_project:
|
345
|
-
rubygems_version: 2.
|
345
|
+
rubygems_version: 2.7.3
|
346
346
|
signing_key:
|
347
347
|
specification_version: 4
|
348
348
|
summary: Authy plugin for Devise
|