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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c40c4ccf07102c60c287a9fdc9c833355a36dec
4
- data.tar.gz: 03b447d4208fe3dba8558bf945efa15ce9806c19
3
+ metadata.gz: fe3459497c3122f6b5e380b429a1d9dbb5b485ea
4
+ data.tar.gz: 9df0a146b6cc26ff2b404354a58728a27ceda9ae
5
5
  SHA512:
6
- metadata.gz: 803533d561e23e4415d7b7510bf933eb335dd427d3b10d7e9e44beaaf547cb92eb70dedd35cf10ae7d80343ab1978a4f124a757bc4e957f1117a323b5e650edc
7
- data.tar.gz: f7dd0954673aecae7967d8948fbd0cd2030347921ca88b20d9fb51b70c1ed5191b94fce1787f84d0facb5da8df13a852b3624b324ffccca299e46247e4e680fe
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.
@@ -0,0 +1,18 @@
1
+ require 'sinatra/base'
2
+
3
+ module Sinatra
4
+ module Userbin
5
+ module Helpers
6
+ def userbin
7
+ binding.pry
8
+ 'hey'
9
+ end
10
+ end
11
+
12
+ def self.registered(app)
13
+ app.helpers Helpers
14
+ end
15
+ end
16
+
17
+ register Userbin
18
+ end
@@ -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, :disable_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
@@ -2,5 +2,6 @@ module Userbin
2
2
  class Event < Model
3
3
  collection_path "users/:user_id/events"
4
4
  belongs_to :user
5
+ has_one :context
5
6
  end
6
7
  end
@@ -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
@@ -2,7 +2,7 @@ module Userbin
2
2
  class Pairing < Model
3
3
  collection_path "users/:user_id/pairings"
4
4
  instance_post :verify
5
- instance_post :set_default
5
+ instance_post :set_default!
6
6
  belongs_to :user
7
7
  end
8
8
  end
@@ -1,5 +1,6 @@
1
1
  module Userbin
2
2
  class Session < Model
3
3
  collection_path "users/:user_id/sessions"
4
+ has_one :context
4
5
  end
5
6
  end
@@ -1,10 +1,7 @@
1
1
  module Userbin
2
2
  class User < Model
3
- custom_post :import
4
- instance_post :lock
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
@@ -1,3 +1,3 @@
1
1
  module Userbin
2
- VERSION = "1.4.6"
2
+ VERSION = "1.4.7"
3
3
  end
data/lib/userbin.rb CHANGED
@@ -27,6 +27,7 @@ end
27
27
  require 'userbin/models/model'
28
28
  require 'userbin/models/event'
29
29
  require 'userbin/models/challenge'
30
+ require 'userbin/models/context'
30
31
  require 'userbin/models/monitoring'
31
32
  require 'userbin/models/pairing'
32
33
  require 'userbin/models/backup_codes'
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.6
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-10-30 00:00:00.000000000 Z
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