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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fc01415394547ff040e49b1a262b2fc437dfb5176fc941e066b2a0a2328a050
4
- data.tar.gz: 8fb8ee3817ad0e76afb7b0b374da4ccfb37fe8cbbaba867d9d019e711ac2bd0f
3
+ metadata.gz: 626b661185acdc250cf5e36c7d6089494ff3163c310a96af4cf8ec80ab369f21
4
+ data.tar.gz: d44f4c0cee2ddf2819d520d59bd06626a70930ccacbb3d7d39002c45585a7b55
5
5
  SHA512:
6
- metadata.gz: 88f9c8adae9140491fea28c79cd41d52e7ef48d361ca2e916b0469548c451898f3f2e78ae3fdea54715d6eedc5d1b464b5a37bd4f7cb155af47f0f3cbbd458ed
7
- data.tar.gz: 2757b8e1044c7ab2f752e101cd58f8cad1fff4167d9fe6d7afcc2f3b80e5f9311f4a65a667b81b708c641997b671c0203aa710491652c18d077063cfbf80ace1
6
+ metadata.gz: 11e3559ee392f31db6842926f2130a27583c530b91b6d98336deaf8a9dc0d259784550bdd4e65cfbb618ffacd47a87acaa29c346946723fce2ba4ab437847cb4
7
+ data.tar.gz: d5a7b655f511e1eec5b9390a0d01ac2d3a2f5b87f26c05eb864d66846139098e62cfe9e18b0dca0e9f5a196db665e3c356ffd28b20b64a213d6e28bb3bf8a37f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flimper_poncho (0.1.1)
4
+ flimper_poncho (0.1.2)
5
5
  faraday (~> 0.15.4)
6
6
  jwt (~> 2.1)
7
7
 
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', name: 'FLIMPER-BACK', resource_code: 'TWITTER_API_BACKEND', level: 'READ').can_perform_action?`
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', email: 'email-1@gmail.com', resource_code: 'application-1', level: 'READ').can_perform_action?`
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:, name:)
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' => @name, 'resource_code' => @resource_code, 'level' => @level }
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:, email:)
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' => @email, 'resource_code' => @resource_code, 'level' => @level }
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
@@ -1,3 +1,3 @@
1
1
  module FlimperPoncho
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flimper_poncho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Gonzaga