devise_userbin 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/devise_userbin/hooks.rb +20 -4
- 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: 74c13514b787b554dbadad7eca6d1b737660645b
|
4
|
+
data.tar.gz: 9d572271db7d6c33536c4cfc3143f639dbbde199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15a1055c682c6988ab1555c41f9092c498b4a3d39d4fcb0a263f083eedc0cfcfbcbd4b2fb6df85ec797b7a6f736373430479407637080c9df96f81dc20055cb3
|
7
|
+
data.tar.gz: 187e7d92904849e389b6106d450d039e5e1fd0a2b434bd8d63ec994c9b138c3b880dc1ed7a97cf418360e497032ec508d446c2b89f808b401db9ab142172f543
|
data/lib/devise_userbin/hooks.rb
CHANGED
@@ -1,24 +1,40 @@
|
|
1
|
+
# Instantiate Userbin client on every request
|
1
2
|
Warden::Manager.on_request do |warden|
|
2
3
|
warden.request.env['userbin'] =
|
3
4
|
Userbin::Client.new(warden.request, warden.cookies)
|
4
5
|
end
|
5
6
|
|
7
|
+
# Track logout.succeeded
|
6
8
|
Warden::Manager.before_logout do |record, warden, opts|
|
7
9
|
if record.respond_to?(:userbin_id)
|
8
|
-
warden.request.env['userbin']
|
10
|
+
userbin = warden.request.env['userbin']
|
11
|
+
userbin.logout
|
12
|
+
userbin.track(name: 'logout.succeeded')
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
16
|
+
# Track login.failed
|
17
|
+
Warden::Manager.before_failure do |env, opts|
|
18
|
+
if opts[:action] == 'unauthenticated'
|
19
|
+
userbin = env['userbin']
|
20
|
+
userbin.track(name: 'login.failed')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Track login.succeeded
|
12
25
|
Warden::Manager.after_set_user :except => :fetch do |record, warden, opts|
|
13
26
|
if record.respond_to?(:userbin_id)
|
14
|
-
|
15
|
-
|
27
|
+
userbin = warden.request.env['userbin']
|
28
|
+
userbin.track(user_id: record._userbin_id, name: 'login.succeeded')
|
29
|
+
userbin.login(record._userbin_id, email: record.email)
|
16
30
|
end
|
17
31
|
end
|
18
32
|
|
33
|
+
# Continous authentication
|
19
34
|
Warden::Manager.after_set_user do |record, warden, opts|
|
20
35
|
if record.respond_to?(:userbin_id)
|
21
36
|
env = warden.request.env
|
22
|
-
|
37
|
+
userbin = env['userbin']
|
38
|
+
userbin.authorize! unless env['userbin.skip_authorization']
|
23
39
|
end
|
24
40
|
end
|
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.7.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-12-29 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.7.0
|
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.7.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|