softwear-lib 2.0.13 → 2.1.0

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: d2054b605e045d72f01a9d41eed7027458abc2f9
4
- data.tar.gz: 889993266539904bf531a524896d1d7f5cfb8b4e
3
+ metadata.gz: aecfca703f9b77b73f1127547fa92dc87751c84e
4
+ data.tar.gz: 27956d8179d672c2dbd5da0f2b74f68a92234b04
5
5
  SHA512:
6
- metadata.gz: e19289acf121735d7745ade3518b082170a6c15bd093e22569d8907389164ae69625c3d227a1e14d97591df93d694b89061b741868b7867d3680eb1c8e71370c
7
- data.tar.gz: 79e701749e95132dfb6c3d226a001b5bb48527fb7e933709554b6d1f34ecbca3c18bd389b4b3fbb407c263437e2f68637c7d647369732a874340164eb8b88d86
6
+ metadata.gz: 80b3888b6813e2b84cd7aff677ca4d320c4a8d314cdf31922bfe716c0fdb9ad02fe9aeee8c737c33646b58d849a80c702555d6599627a9a232cbe12fac18096e
7
+ data.tar.gz: 7ea41972013e408341024c66c15a892eb07b7bb9a34857f1b76bf6a9104aeddf4076cf649085f0ae0adc16bdb53d9f106828122a48de935fce1471677e912cad
@@ -0,0 +1,29 @@
1
+ # Provides a routing constraint that makes sure a user is authenticated
2
+ # before a route can be resolved.
3
+ #
4
+ # (used for autenticating sidekiq)
5
+
6
+ module Softwear
7
+ module Auth
8
+ class Routing
9
+ def initialize(user_class, pred = nil)
10
+ @user_class = user_class
11
+ @pred = pred
12
+ end
13
+
14
+ def matches?(request)
15
+ if user = @user_class.auth(request.session[:auth_token])
16
+ !@pred || @pred.call(user)
17
+ else
18
+ false
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ ActionDispatch::Routing::Mapper.class_eval do
26
+ def authenticate(user_class, pred = nil, &block)
27
+ constraints(::Softwear::Auth::Routing.new(user_class, pred), &block)
28
+ end
29
+ end
@@ -47,7 +47,7 @@ module Softwear
47
47
  end
48
48
 
49
49
  # ====================
50
- # Action called when a NotSignedInError is raised.
50
+ # Action called when an AuthServerDown error is raised.
51
51
  # ====================
52
52
  def auth_server_down(error)
53
53
  respond_to do |format|
@@ -1,5 +1,5 @@
1
1
  module Softwear
2
2
  module Library
3
- VERSION = "2.0.13"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softwear-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Baillie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2016-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,6 +101,7 @@ files:
101
101
  - lib/softwear/auth/emails_helper.rb
102
102
  - lib/softwear/auth/helper.rb
103
103
  - lib/softwear/auth/model.rb
104
+ - lib/softwear/auth/routing.rb
104
105
  - lib/softwear/auth/spec.rb
105
106
  - lib/softwear/auth/standard_model.rb
106
107
  - lib/softwear/auth/stubbed_model.rb