softwear-lib 2.0.13 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aecfca703f9b77b73f1127547fa92dc87751c84e
|
4
|
+
data.tar.gz: 27956d8179d672c2dbd5da0f2b74f68a92234b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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-
|
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
|