flimper_poncho 0.1.3 → 0.1.4

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: 1f5039241ceb9557663fa4c2f9b0c15f8cf286c1ea30cff4475b4e939d95ccad
4
- data.tar.gz: da20fb723e56c0153e2b62f8b873f5bb10e9c4ee8397fb0a9ed8feab32b34f8f
3
+ metadata.gz: 77fb1fc47468d3a16fa802f29af229e410789edc3635791e60ef5e92160f3f34
4
+ data.tar.gz: 83b51e47a380b52391db26599d86457dec97de7a36c0f8d316b43451704ad388
5
5
  SHA512:
6
- metadata.gz: 195fa235f180c2e0ef3015e747b456dd1ec12cc81969630fd54ea446e4c6b7258c61bc86307ca8e5f53ebea3947f2427c51486b1e17daa2f6ba2fdc1e380e249
7
- data.tar.gz: cd24ba36deb9fffeac5f23a9feadb59fdd5e94debd53b8decab667f99d214e7e24fb9ad95a647e41e986045d3fc33934b3a3bf5dc54fa2b2eead862458198518
6
+ metadata.gz: 300ec4e340859e539bfc00dc605ccf233f2af6564777044ce50917ad0fbf14fbc5fe561ba99e1a772a4ffe91d7d9f9488dd3cb9f8be93f5e3af71dc491332a13
7
+ data.tar.gz: 491c7303b4f50bc5ad562a02b2002fa48be759910cd112876bcf9de945d358f500745dcbfa61d4708956f8d7b2bab0603b9b64ac03d24d22ab46d3d73dc9b79c
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
  .byebug_history
13
13
  *.gem
14
+ .idea/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flimper_poncho (0.1.3)
4
+ flimper_poncho (0.1.4)
5
5
  faraday
6
6
  jwt
7
7
 
@@ -3,6 +3,7 @@ require 'flimper_poncho/jwts/issuers/for_api_clients'
3
3
  require 'flimper_poncho/jwts/issuers/for_users'
4
4
  require 'flimper_poncho/permissions/checkers/for_api_clients'
5
5
  require 'flimper_poncho/permissions/checkers/for_users'
6
+ require 'flimper_poncho/users/queries/find'
6
7
 
7
8
  module FlimperPoncho
8
9
  end
@@ -0,0 +1,27 @@
1
+ module FlimperPoncho
2
+ module Users
3
+ module Queries
4
+ class Find
5
+ def initialize(jwt_token:)
6
+ @jwt_token = jwt_token
7
+ end
8
+
9
+ def run
10
+ OpenStruct.new(id: decoded_jwt['id'], email: decoded_jwt['email'], permissions: permissions)
11
+ end
12
+
13
+ private
14
+
15
+ def decoded_jwt
16
+ @decoded_jwt ||= JWT.decode(@jwt_token, ENV.fetch('PONCHO_API_SIGNATURE_KEY'), true, algorithm: 'HS256')[0]
17
+ end
18
+
19
+ def permissions
20
+ @permissions ||= decoded_jwt.dig('permissions').map do |perm|
21
+ OpenStruct.new(email: perm['email'], resource_code: perm['resource_code'], level: perm['level'])
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module FlimperPoncho
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flimper_poncho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Gonzaga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2019-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - lib/flimper_poncho/permissions/checkers/for_api_clients.rb
164
164
  - lib/flimper_poncho/permissions/checkers/for_users.rb
165
165
  - lib/flimper_poncho/permissions/checkers/template.rb
166
+ - lib/flimper_poncho/users/queries/find.rb
166
167
  - lib/flimper_poncho/version.rb
167
168
  homepage: https://github.com/flimperapp/poncho_gem
168
169
  licenses: