zaikio-jwt_auth 0.1.6 → 0.1.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/lib/zaikio/jwt_auth.rb +2 -1
- data/lib/zaikio/jwt_auth/token_data.rb +18 -6
- data/lib/zaikio/jwt_auth/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa5cedf782b4972795398012fb5d50f5156995a34951a077b49ab8c72d47af6c
|
4
|
+
data.tar.gz: 2e76b158eaddb1c7993412883fe0926af121ac1e959c8f0ff6e9fdc4a71fd17c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c837c489820a0bfe172813a22e0a974bb5686724826db11a76c88cf08085c2ca250124310dedc95146e640b6755ad32e18490a35cf617270c736ab63fbe46b1
|
7
|
+
data.tar.gz: da668d14415c81d38a08b8d1bed52390b7040476301ac049a43c63a8e96eb973b229ebd5ad689b215b244b99dd18edbc0e3ff78f24eb84d1245babb977b09cdf
|
data/lib/zaikio/jwt_auth.rb
CHANGED
@@ -107,7 +107,8 @@ module Zaikio
|
|
107
107
|
def show_error_if_authorize_by_jwt_scopes_fails(token_data)
|
108
108
|
return if token_data.scope_by_configurations?(
|
109
109
|
self.class.authorize_by_jwt_scopes,
|
110
|
-
action_name
|
110
|
+
action_name,
|
111
|
+
self
|
111
112
|
)
|
112
113
|
|
113
114
|
render_error("unpermitted_scope")
|
@@ -35,14 +35,16 @@ module Zaikio
|
|
35
35
|
|
36
36
|
# scope_options is an array of objects with:
|
37
37
|
# scope, app_name (optional), except/only (array, optional)
|
38
|
-
def scope_by_configurations?(scope_configurations, action_name)
|
38
|
+
def scope_by_configurations?(scope_configurations, action_name, context)
|
39
39
|
configuration = scope_configurations.find do |scope_configuration|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
action_matches = action_matches_config?(scope_configuration, action_name)
|
41
|
+
|
42
|
+
if action_matches && scope_configuration[:if] && !context.instance_exec(&scope_configuration[:if])
|
43
|
+
false
|
44
|
+
elsif action_matches && scope_configuration[:unless] && context.instance_exec(&scope_configuration[:unless])
|
45
|
+
false
|
44
46
|
else
|
45
|
-
|
47
|
+
action_matches
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -51,6 +53,16 @@ module Zaikio
|
|
51
53
|
scope?(configuration[:scopes], action_name, configuration[:app_name])
|
52
54
|
end
|
53
55
|
|
56
|
+
def action_matches_config?(scope_configuration, action_name)
|
57
|
+
if scope_configuration[:only]
|
58
|
+
Array(scope_configuration[:only]).any? { |a| a.to_s == action_name }
|
59
|
+
elsif scope_configuration[:except]
|
60
|
+
Array(scope_configuration[:except]).none? { |a| a.to_s == action_name }
|
61
|
+
else
|
62
|
+
true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
54
66
|
def scope?(allowed_scopes, action_name, app_name = nil)
|
55
67
|
app_name ||= Zaikio::JWTAuth.configuration.app_name
|
56
68
|
Array(allowed_scopes).map(&:to_s).any? do |allowed_scope|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-jwt_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crispy Mountain GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 6.0.
|
33
|
+
version: 6.0.2.2
|
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: 6.0.
|
40
|
+
version: 6.0.2.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jwt
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|