avo 2.18.0 → 2.18.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3aeba1710c17c48914eb88a8d2c6d995903b292ad1d41ba68ebf6ca60ffb23d
4
- data.tar.gz: 3f2b5b18f03ca4bec42fc0101c397a8150de001c98d3510f5b3d49a9a97ac54d
3
+ metadata.gz: 7079bc6f71897afdcc083d49d88255d5a3e903e130a9c054e069976dc9038bc0
4
+ data.tar.gz: c618bf337578ddc521f6be2c92eb1c1bfc76f4e7956c5f4a7393e31326f49f02
5
5
  SHA512:
6
- metadata.gz: c2e2850291a795e8ba15793ab8a7b4132322ae567d975fb0c70c73a4a807788bf67ca32cb84320a02d62096fe06ae745388ecab89f01b2f5d396e58b1f8d71ce
7
- data.tar.gz: 3f66906bce086a54f94ac1c39cbbeb8b5100fe7a61752d3eb0f3d242a1eabdd2e3ad004aafbcac9f35613e1a64a509d11b8c5a267accf9b058502102d5f4b7f1
6
+ metadata.gz: 7b32f335e16778be0647bd74c1579f5842d01b74c836655040d165e64bcb5325a7f23b43bb01a31f455af6f58ae3ecac968cb301e8737d4d36734f2ea1d88dcd
7
+ data.tar.gz: c9a37f010a3b138f64f7f10d31b077a94f06d48539bffb635f6b6e0d35d2d56b76d2b25cd34e31e189fbf72911a91b52910bb341391a13edff6b6c79cac3c48f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.18.0)
4
+ avo (2.18.1)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
data/config/master.key ADDED
@@ -0,0 +1 @@
1
+ 2aeb23d82b909d9c6b5abb62f7058c2a
@@ -0,0 +1,37 @@
1
+ module Avo
2
+ module Services
3
+ module AuthorizationClients
4
+ class NilClient
5
+ def authorize(user, record, action, policy_class: nil)
6
+ true
7
+ end
8
+
9
+ def policy(user, record)
10
+ NilPolicy.new
11
+ end
12
+
13
+ def policy!(user, record)
14
+ NilPolicy.new
15
+ end
16
+
17
+ def apply_policy(user, model, policy_class: nil)
18
+ model
19
+ end
20
+
21
+ class NilPolicy
22
+ def initialize(user = nil, record = nil)
23
+ end
24
+ # rubocop:enable Style/RedundantInitialize
25
+
26
+ def method_missing(method, *args, &block)
27
+ self
28
+ end
29
+
30
+ def respond_to_missing?
31
+ true
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -9,8 +9,12 @@ module Avo
9
9
  def client
10
10
  client = Avo.configuration.authorization_client
11
11
 
12
+ client = nil if Avo::App.license.lacks(:authorization)
13
+
12
14
  klass = case client
13
- when :pundit, nil
15
+ when nil
16
+ nil_client
17
+ when :pundit
14
18
  pundit_client
15
19
  else
16
20
  if client.is_a?(String)
@@ -92,8 +96,14 @@ module Avo
92
96
  end
93
97
 
94
98
  def pundit_client
99
+ raise Avo::MissingGemError.new("Please add `gem 'pundit'` to your Gemfile.") unless defined?(Pundit)
100
+
95
101
  Avo::Services::AuthorizationClients::PunditClient
96
102
  end
103
+
104
+ def nil_client
105
+ Avo::Services::AuthorizationClients::NilClient
106
+ end
97
107
  end
98
108
 
99
109
  def initialize(user = nil, record = nil, policy_class: nil)
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.18.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.18.1" unless const_defined?(:VERSION)
3
3
  end
data/lib/avo.rb CHANGED
@@ -48,6 +48,8 @@ module Avo
48
48
  class NotAuthorizedError < StandardError; end
49
49
 
50
50
  class NoPolicyError < StandardError; end
51
+
52
+ class MissingGemError < StandardError; end
51
53
  end
52
54
 
53
55
  loader.eager_load
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.0
4
+ version: 2.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-25 00:00:00.000000000 Z
12
+ date: 2022-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -1708,6 +1708,7 @@ files:
1708
1708
  - config/credentials.yml.enc
1709
1709
  - config/i18n-tasks.yml
1710
1710
  - config/initializers/pagy.rb
1711
+ - config/master.key
1711
1712
  - config/routes.rb
1712
1713
  - config/spring.rb
1713
1714
  - db/factories.rb
@@ -1828,6 +1829,7 @@ files:
1828
1829
  - lib/avo/resources/controls/execution_context.rb
1829
1830
  - lib/avo/resources/controls/items_holder.rb
1830
1831
  - lib/avo/resources/controls/link_to.rb
1832
+ - lib/avo/services/authorization_clients/nil_client.rb
1831
1833
  - lib/avo/services/authorization_clients/pundit_client.rb
1832
1834
  - lib/avo/services/authorization_service.rb
1833
1835
  - lib/avo/services/encryption_service.rb