nexus_cqrs 0.4.3 → 0.4.6

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: 2ad110fb96498636aa174c3d45aa7783177fb7e5a2475e828f6e694adf392b46
4
- data.tar.gz: 35fd22cd65fd520c91c93629b365f4573fbc0787158212b12dd3fb1241e0da43
3
+ metadata.gz: f161457b535982dea76014d06a36f559a37171e17726ebdbde1d3a6e35c988b8
4
+ data.tar.gz: bba7db5996f94df23f40710d89f89bda13ae5d2d6ac960377063d96e0270655c
5
5
  SHA512:
6
- metadata.gz: faee92b66ddcd2cdcd70fb315f444c2f226ff194ff528eb5c4e3f0a654c5e274e7715df987883b7a0512cbf0245a84824dd24829aa879277424c675435ea5169
7
- data.tar.gz: 172b58d34c2da223e41e933fd0df3b379450d0d9ec0ce89095e6581ff894006224614cb62455d7d5223a376988413f3e6d7a98e28d1d502ad58b349c3a075fa8
6
+ metadata.gz: 3571626f27df1a94b200bb4a249740c3e12fed54781f4eeb349e3ddf7b07651bb62991e07d77c2a0c85cc9a78149b6ebee471d5e93d9464a39a1a5d4165ec3ca
7
+ data.tar.gz: 02ecda8ebdde1b2c3780f8e5797d8209d83730317ff2d9f53d1bd2762dcd17f30166a8fea62779ca8327b8053fe84679fcc7f051499c184e60539323eae28189
data/Gemfile.lock CHANGED
@@ -55,7 +55,7 @@ GEM
55
55
  parallel (1.21.0)
56
56
  parser (3.0.2.0)
57
57
  ast (~> 2.4.1)
58
- pundit (2.1.1)
58
+ pundit (2.2.0)
59
59
  activesupport (>= 3.0.0)
60
60
  racc (1.6.0)
61
61
  rack (2.2.3)
@@ -6,7 +6,7 @@ module NexusCqrs
6
6
  # Concern used to provide authorisation abilities to handlers and other classes. Overrides pundit's `authorize` method
7
7
  # and creates helpers for the permission_provider
8
8
  module Auth
9
- include Pundit
9
+ include Pundit::Authorization
10
10
 
11
11
  # Overrides pundit's `authorize` method, allowing the message to be passed
12
12
  #
@@ -17,7 +17,7 @@ module NexusCqrs
17
17
  query ||= Strings::Case.snakecase(message.demodularised_class_name) + '?'
18
18
 
19
19
  # Retreive the policy class object from the type of record we are passing in
20
- policy_class ||= PolicyFinder.new(record).policy
20
+ policy_class ||= Pundit::PolicyFinder.new(record).policy
21
21
 
22
22
  # Pull context variables from command
23
23
  user = message.metadata[:current_user]
@@ -25,7 +25,7 @@ module NexusCqrs
25
25
 
26
26
  # Instantiate new policy class, with context
27
27
  policy = policy_class.new(UserContext.new(user, global_permissions), record)
28
- raise NotAuthorizedError, query: query, record: record, policy: policy unless policy.public_send(query)
28
+ raise Pundit::NotAuthorizedError, query: query, record: record, policy: policy unless policy.public_send(query)
29
29
 
30
30
  record.is_a?(Array) ? record.last : record
31
31
  end
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require 'request_store'
3
+
2
4
  module NexusCqrs
3
5
  module Auth
4
6
  class PermissionProvider
@@ -53,8 +55,12 @@ module NexusCqrs
53
55
  return [] if @user_id.nil?
54
56
 
55
57
  # retrieve entity-specific permissions from DB and map to hash
56
- entity_permissions = permission_model.where(user_id: @user_id, entity_id: entity_id)
57
- .map { |p| { global: false, key: p.permission } }
58
+ entity_permissions = if cached_permissions(permission_model).key?(entity_id)
59
+ cached_permissions(permission_model)[entity_id]
60
+ .map { |p| { global: false, key: p } }
61
+ else
62
+ []
63
+ end
58
64
 
59
65
  # Map global permissions to hash
60
66
  global_permissions = @global_permissions.map { |p| { global: true, key: p } }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module NexusCqrs
3
- # Leave this as 0.4.3 in order for CI process to replace with the tagged version.
4
- VERSION = '0.4.3'
3
+ # Leave this as 0.4.6 in order for CI process to replace with the tagged version.
4
+ VERSION = '0.4.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_cqrs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Lovett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: generator_spec
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.2.32
157
+ rubygems_version: 3.3.9
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Core package for the nexus cqrs gem