userbin 1.4.6 → 1.4.7
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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/sinatra/userbin.rb +18 -0
- data/lib/userbin/client.rb +1 -1
- data/lib/userbin/models/context.rb +18 -0
- data/lib/userbin/models/event.rb +1 -0
- data/lib/userbin/models/model.rb +11 -1
- data/lib/userbin/models/pairing.rb +1 -1
- data/lib/userbin/models/session.rb +1 -0
- data/lib/userbin/models/user.rb +2 -5
- data/lib/userbin/version.rb +1 -1
- data/lib/userbin.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3459497c3122f6b5e380b429a1d9dbb5b485ea
|
4
|
+
data.tar.gz: 9df0a146b6cc26ff2b404354a58728a27ceda9ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2274aa29cfa87f220ababb741014d90946da71b0d31d2a20b208e2efd8b1b544befb43ba79820febfcaa82823ff78a4a0a0abc8b36cfa3c8ed8ed324f9c78e
|
7
|
+
data.tar.gz: 817146fe462f1147baccf117ea78f783d42173d2a2877142e9939c774eab0837cd73c96140329ec5da86dbf0a62f501fe4f57cc61bf656f6b2f5b0035cd57994
|
data/README.md
CHANGED
@@ -201,8 +201,8 @@ end
|
|
201
201
|
For the sake of flexibility, two-factor authentication isn't enabled automatically when you add your first pairing.
|
202
202
|
|
203
203
|
```ruby
|
204
|
-
userbin.enable_mfa
|
205
|
-
userbin.disable_mfa
|
204
|
+
userbin.enable_mfa!
|
205
|
+
userbin.disable_mfa!
|
206
206
|
```
|
207
207
|
|
208
208
|
### Authenticating
|
@@ -278,7 +278,7 @@ end
|
|
278
278
|
Set a pairing as the default one.
|
279
279
|
|
280
280
|
```ruby
|
281
|
-
userbin.pairings.set_default('yt9BkoHzcQoou4jqbQbJUqqMdxyxvCBr')
|
281
|
+
userbin.pairings.set_default!('yt9BkoHzcQoou4jqbQbJUqqMdxyxvCBr')
|
282
282
|
```
|
283
283
|
|
284
284
|
Remove a pairing. If you remove the default pairing, two-factor authentication will be disabled.
|
data/lib/userbin/client.rb
CHANGED
@@ -15,7 +15,7 @@ module Userbin
|
|
15
15
|
|
16
16
|
install_proxy_methods :challenges, :events, :sessions, :pairings,
|
17
17
|
:backup_codes, :generate_backup_codes, :trusted_devices,
|
18
|
-
:enable_mfa
|
18
|
+
:enable_mfa!, :disable_mfa!
|
19
19
|
|
20
20
|
def initialize(request, cookies, opts = {})
|
21
21
|
# Save a reference in the per-request store so that the request
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Userbin
|
2
|
+
class Context < Model
|
3
|
+
def user_agent
|
4
|
+
if attributes['user_agent']
|
5
|
+
Userbin::Location.new(attributes['user_agent'])
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def location
|
10
|
+
if attributes['location']
|
11
|
+
Userbin::Location.new(attributes['location'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class UserAgent < Model; end
|
17
|
+
class Location < Model; end
|
18
|
+
end
|
data/lib/userbin/models/event.rb
CHANGED
data/lib/userbin/models/model.rb
CHANGED
@@ -18,6 +18,16 @@ module Userbin
|
|
18
18
|
super(args)
|
19
19
|
end
|
20
20
|
|
21
|
+
# Transform model.user.id to model.user_id to allow calls on nested models
|
22
|
+
def attributes
|
23
|
+
attrs = super
|
24
|
+
if attrs['user'] && attrs['user']['id']
|
25
|
+
attrs.merge!('user_id' => attrs['user']['id'])
|
26
|
+
attrs.delete 'user'
|
27
|
+
end
|
28
|
+
attrs
|
29
|
+
end
|
30
|
+
|
21
31
|
# Remove the auto-generated embedded User model to prevent recursion
|
22
32
|
def to_json
|
23
33
|
attrs = attributes
|
@@ -53,7 +63,7 @@ module Userbin
|
|
53
63
|
#
|
54
64
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
55
65
|
def #{action}(params={})
|
56
|
-
self.class.#{method}("\#{request_path}/#{action}", params)
|
66
|
+
self.class.#{method}("\#{request_path}/#{action.to_s.delete('!')}", params)
|
57
67
|
end
|
58
68
|
RUBY
|
59
69
|
end
|
data/lib/userbin/models/user.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
module Userbin
|
2
2
|
class User < Model
|
3
|
-
|
4
|
-
instance_post :
|
5
|
-
instance_post :unlock
|
6
|
-
instance_post :enable_mfa
|
7
|
-
instance_post :disable_mfa
|
3
|
+
instance_post :enable_mfa!
|
4
|
+
instance_post :disable_mfa!
|
8
5
|
|
9
6
|
has_many :challenges
|
10
7
|
has_many :events
|
data/lib/userbin/version.rb
CHANGED
data/lib/userbin.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userbin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: her
|
@@ -172,6 +172,7 @@ extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
174
|
- README.md
|
175
|
+
- lib/sinatra/userbin.rb
|
175
176
|
- lib/userbin.rb
|
176
177
|
- lib/userbin/client.rb
|
177
178
|
- lib/userbin/configuration.rb
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- lib/userbin/jwt.rb
|
181
182
|
- lib/userbin/models/backup_codes.rb
|
182
183
|
- lib/userbin/models/challenge.rb
|
184
|
+
- lib/userbin/models/context.rb
|
183
185
|
- lib/userbin/models/event.rb
|
184
186
|
- lib/userbin/models/model.rb
|
185
187
|
- lib/userbin/models/monitoring.rb
|