devise_userbin 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/devise/devise_userbin_controller.rb +4 -3
- data/app/controllers/devise/security_settings_controller.rb +1 -2
- data/lib/devise_userbin.rb +5 -5
- data/lib/devise_userbin/controllers/helpers.rb +10 -3
- data/lib/devise_userbin/hooks.rb +18 -26
- data/lib/devise_userbin/model.rb +2 -3
- data/lib/devise_userbin/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f002bedf94193a3be8c19a48c92c1e31288c5e
|
4
|
+
data.tar.gz: cd8ee013cb8ff1c4915b29bc7fcf4761db799aff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58e57d7da0e13a6d88e06f007f73e26e8deefc865e24a4ec2baf2777ab3949e0a16719790b23bf043833bb1d884d879246483a888433dfbe37db82ecb405704b
|
7
|
+
data.tar.gz: f0b4b273c918a6c5812dc0da9c9d8313dac3b06be65261f6bbee05a3a867aae9f8a6c1b6ec88b02e72702cab36687ca80f8b1726a0152bb5c151642364e403cc
|
@@ -10,8 +10,9 @@ class Devise::DeviseUserbinController < DeviseController
|
|
10
10
|
|
11
11
|
Devise.mappings.keys.flatten.any? do |scope|
|
12
12
|
begin
|
13
|
-
|
14
|
-
|
13
|
+
send("current_#{scope_name}") # initialize after_set_user in warden
|
14
|
+
env['userbin'].two_factor_verify(params[:code])
|
15
|
+
|
15
16
|
set_flash_message :notice, :success
|
16
17
|
redirect_to after_sign_in_path_for(scope)
|
17
18
|
rescue Userbin::UserUnauthorizedError => error
|
@@ -21,7 +22,7 @@ class Devise::DeviseUserbinController < DeviseController
|
|
21
22
|
rescue Userbin::Forbidden => error
|
22
23
|
sign_out_with_message(:no_retries_remaining, :alert)
|
23
24
|
rescue Userbin::Error => error
|
24
|
-
sign_out_with_message(:
|
25
|
+
sign_out_with_message(:error, :alert)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -2,7 +2,6 @@ class Devise::SecuritySettingsController < DeviseController
|
|
2
2
|
include Devise::Controllers::Helpers
|
3
3
|
|
4
4
|
def show
|
5
|
-
|
6
|
-
redirect_to Userbin.security_settings_url(session_token)
|
5
|
+
redirect_to env['userbin'].security_settings_url
|
7
6
|
end
|
8
7
|
end
|
data/lib/devise_userbin.rb
CHANGED
@@ -6,11 +6,6 @@ require 'devise_userbin/hooks'
|
|
6
6
|
require 'devise_userbin/import'
|
7
7
|
require 'userbin'
|
8
8
|
|
9
|
-
if defined?(Rails::Railtie)
|
10
|
-
require 'devise_userbin/railtie'
|
11
|
-
Rails::Engine
|
12
|
-
end
|
13
|
-
|
14
9
|
module Devise
|
15
10
|
mattr_accessor :userbin_api_secret
|
16
11
|
@@userbin_api_secret = ''
|
@@ -25,6 +20,11 @@ module DeviseUserbin
|
|
25
20
|
end
|
26
21
|
end
|
27
22
|
|
23
|
+
if defined?(Rails::Railtie)
|
24
|
+
require 'devise_userbin/railtie'
|
25
|
+
Rails::Engine
|
26
|
+
end
|
27
|
+
|
28
28
|
Devise.add_module(:userbin,
|
29
29
|
:controller => :two_factor_authentication,
|
30
30
|
:route => :userbin,
|
@@ -10,11 +10,18 @@ module DeviseUserbin
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def handle_two_factor_authentication
|
13
|
-
|
13
|
+
if !devise_controller? && env['userbin'].authorized?
|
14
14
|
Devise.mappings.keys.flatten.any? do |scope|
|
15
15
|
if signed_in?(scope)
|
16
|
-
|
17
|
-
|
16
|
+
begin
|
17
|
+
factor = env['userbin'].two_factor_authenticate!
|
18
|
+
|
19
|
+
# Show form and message specific to the current factor
|
20
|
+
case factor
|
21
|
+
when :authenticator
|
22
|
+
handle_required_two_factor_authentication(scope)
|
23
|
+
end
|
24
|
+
rescue Userbin::Error # ignore for now
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
data/lib/devise_userbin/hooks.rb
CHANGED
@@ -1,34 +1,26 @@
|
|
1
|
+
Warden::Manager.on_request do |warden|
|
2
|
+
warden.request.env['userbin'] = Userbin::Client.new(warden.request)
|
3
|
+
end
|
4
|
+
|
1
5
|
# Everytime current_<scope> is prepared
|
2
6
|
#
|
3
7
|
Warden::Manager.after_set_user :only => :fetch do |record, warden, opts|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
email: record.email
|
13
|
-
},
|
14
|
-
context: {
|
15
|
-
ip: warden.request.ip,
|
16
|
-
user_agent: warden.request.user_agent
|
17
|
-
}
|
18
|
-
})
|
19
|
-
|
20
|
-
warden.request.session["#{scope}_userbin"] = session_token
|
21
|
-
|
22
|
-
rescue Userbin::Error => error
|
23
|
-
warden.logout(scope)
|
24
|
-
throw :warden, :scope => scope, :message => :timeout
|
8
|
+
if record.respond_to?(:_userbin_id)
|
9
|
+
begin
|
10
|
+
userbin = warden.request.env['userbin']
|
11
|
+
userbin.authorize!(record._userbin_id, { email: record.email })
|
12
|
+
rescue Userbin::Error
|
13
|
+
warden.logout(opts[:scope])
|
14
|
+
throw :warden, :scope => opts[:scope], :message => :timeout
|
15
|
+
end
|
25
16
|
end
|
26
|
-
|
27
17
|
end
|
28
18
|
|
29
19
|
Warden::Manager.before_logout do |record, warden, opts|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
20
|
+
if record.respond_to?(:userbin_id)
|
21
|
+
begin
|
22
|
+
userbin = warden.request.env['userbin']
|
23
|
+
userbin.logout
|
24
|
+
rescue Userbin::Error; end
|
25
|
+
end
|
34
26
|
end
|
data/lib/devise_userbin/model.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_userbin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan Brissmyr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-12 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: 1.
|
33
|
+
version: 1.1.1
|
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: 1.
|
40
|
+
version: 1.1.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|