flimper_poncho 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/flimper_poncho/permissions/checkers/for_api_clients.rb +2 -3
- data/lib/flimper_poncho/permissions/checkers/for_users.rb +2 -3
- data/lib/flimper_poncho/permissions/checkers/template.rb +1 -1
- data/lib/flimper_poncho/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626b661185acdc250cf5e36c7d6089494ff3163c310a96af4cf8ec80ab369f21
|
4
|
+
data.tar.gz: d44f4c0cee2ddf2819d520d59bd06626a70930ccacbb3d7d39002c45585a7b55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e3559ee392f31db6842926f2130a27583c530b91b6d98336deaf8a9dc0d259784550bdd4e65cfbb618ffacd47a87acaa29c346946723fce2ba4ab437847cb4
|
7
|
+
data.tar.gz: d5a7b655f511e1eec5b9390a0d01ac2d3a2f5b87f26c05eb864d66846139098e62cfe9e18b0dca0e9f5a196db665e3c356ffd28b20b64a213d6e28bb3bf8a37f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -38,11 +38,11 @@ Or install it yourself as:
|
|
38
38
|
|
39
39
|
- Check ApiClient permission:
|
40
40
|
|
41
|
-
`Permissions::Checkers::ForApiClients.new(jwt_token: 'valid_jwt',
|
41
|
+
`Permissions::Checkers::ForApiClients.new(jwt_token: 'valid_jwt', resource_code: 'TWITTER_API_BACKEND', level: 'READ').can_perform_action?`
|
42
42
|
|
43
43
|
- Check User permission:
|
44
44
|
|
45
|
-
`Permissions::Checkers::ForUsers.new(jwt_token: 'valid_jwt',
|
45
|
+
`Permissions::Checkers::ForUsers.new(jwt_token: 'valid_jwt', resource_code: 'application-1', level: 'READ').can_perform_action?`
|
46
46
|
|
47
47
|
## Development
|
48
48
|
|
@@ -5,15 +5,14 @@ module Permissions
|
|
5
5
|
class ForApiClients < Permissions::Checkers::Template
|
6
6
|
attr_reader :jwt_token
|
7
7
|
|
8
|
-
def initialize(jwt_token:, resource_code:, level
|
8
|
+
def initialize(jwt_token:, resource_code:, level:)
|
9
9
|
@jwt_token = jwt_token
|
10
10
|
@resource_code = resource_code
|
11
11
|
@level = level
|
12
|
-
@name = name
|
13
12
|
end
|
14
13
|
|
15
14
|
def permission_query
|
16
|
-
{ 'name' =>
|
15
|
+
{ 'name' => decoded_jwt.dig('name'), 'resource_code' => @resource_code, 'level' => @level }
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -5,15 +5,14 @@ module Permissions
|
|
5
5
|
class ForUsers < Permissions::Checkers::Template
|
6
6
|
attr_reader :jwt_token
|
7
7
|
|
8
|
-
def initialize(jwt_token:, resource_code:, level
|
8
|
+
def initialize(jwt_token:, resource_code:, level:)
|
9
9
|
@jwt_token = jwt_token
|
10
10
|
@resource_code = resource_code
|
11
11
|
@level = level
|
12
|
-
@email = email
|
13
12
|
end
|
14
13
|
|
15
14
|
def permission_query
|
16
|
-
{ 'email' =>
|
15
|
+
{ 'email' => decoded_jwt.dig('email'), 'resource_code' => @resource_code, 'level' => @level }
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -16,7 +16,7 @@ module Permissions
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def decoded_jwt
|
19
|
-
JWT.decode(jwt_token, ENV.fetch('PONCHO_API_SIGNATURE_KEY'), true, algorithm: 'HS256')[0]
|
19
|
+
@decoded_jwt ||= JWT.decode(jwt_token, ENV.fetch('PONCHO_API_SIGNATURE_KEY'), true, algorithm: 'HS256')[0]
|
20
20
|
end
|
21
21
|
|
22
22
|
def permission_query
|