avo 2.17.1.pre.1.zeitwerk.eager.load.dir → 2.17.1.pre.2.customauthorizationclients
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 +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +6 -13
- data/app/components/avo/panel_component.html.erb +4 -2
- data/app/components/avo/panel_component.rb +4 -2
- data/app/components/avo/tab_switcher_component.html.erb +1 -1
- data/app/components/avo/tab_switcher_component.rb +0 -2
- data/app/controllers/avo/application_controller.rb +9 -17
- data/app/controllers/avo/associations_controller.rb +2 -5
- data/app/helpers/avo/application_helper.rb +0 -4
- data/avo.gemspec +2 -2
- data/config/routes.rb +1 -1
- data/lib/avo/app.rb +0 -6
- data/lib/avo/configuration.rb +2 -0
- data/lib/avo/dynamic_router.rb +15 -19
- data/lib/avo/engine.rb +0 -9
- data/lib/avo/services/authorization_clients/pundit_client.rb +51 -0
- data/lib/avo/services/authorization_service.rb +43 -62
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +4 -0
- data/lib/generators/avo/templates/initializer/avo.tt +1 -0
- data/lib/generators/avo/templates/locales/avo.nb.yml +1 -1
- data/lib/generators/avo/templates/locales/avo.nn.yml +7 -7
- data/public/avo-assets/avo.base.css +6 -12
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e76409a6dd8d5c3a89a467e4cbed5e46f0c292988fd60efa5a1c673be10e36a
|
4
|
+
data.tar.gz: '09bde2e9be219d3f9af5fb3256ee9ed60c77d86d587e8f9131c8d3e95d03ef29'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82ceba1946394ea1bea5cf4ef8283d75ddb40fdcfcfdd55ee19cad8aff34ed873698442dd846711134e6d961e288ca723cf8f9fab0aab122c0a49319e432ff05
|
7
|
+
data.tar.gz: 3829a9ec1348318c537aee5954463c41864ee710790a8a333c2f075102d205ec90e50e70f766051aa2e892c2d0d8609b0bedc299a502d557a0806e9c34107269
|
data/Gemfile
CHANGED
@@ -114,7 +114,7 @@ end
|
|
114
114
|
gem "rubocop"
|
115
115
|
gem "rubocop-shopify", require: false
|
116
116
|
|
117
|
-
|
117
|
+
gem "zeitwerk", "~> 2.3"
|
118
118
|
|
119
119
|
gem "httparty"
|
120
120
|
|
@@ -153,4 +153,3 @@ gem 'acts-as-taggable-on', '~> 9.0'
|
|
153
153
|
gem "bundler-integrity", "~> 1.0"
|
154
154
|
|
155
155
|
gem 'erb-formatter'
|
156
|
-
gem "zeitwerk", github: "fxn/zeitwerk"
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/fxn/zeitwerk.git
|
3
|
-
revision: 50515063d309bf50cb1fdcffa7558ca26d124b3f
|
4
|
-
specs:
|
5
|
-
zeitwerk (2.6.1)
|
6
|
-
|
7
1
|
PATH
|
8
2
|
remote: .
|
9
3
|
specs:
|
10
|
-
avo (2.17.1.pre.
|
4
|
+
avo (2.17.1.pre.2.customauthorizationclients)
|
11
5
|
active_link_to
|
12
6
|
addressable
|
13
7
|
breadcrumbs_on_rails
|
@@ -23,7 +17,8 @@ PATH
|
|
23
17
|
pundit
|
24
18
|
rails (>= 6.0)
|
25
19
|
turbo-rails
|
26
|
-
view_component
|
20
|
+
view_component (= 2.60)
|
21
|
+
zeitwerk
|
27
22
|
|
28
23
|
GEM
|
29
24
|
remote: https://rubygems.org/
|
@@ -273,8 +268,6 @@ GEM
|
|
273
268
|
nokogiri (1.13.8)
|
274
269
|
mini_portile2 (~> 2.8.0)
|
275
270
|
racc (~> 1.4)
|
276
|
-
nokogiri (1.13.8-x86_64-linux)
|
277
|
-
racc (~> 1.4)
|
278
271
|
orm_adapter (0.5.0)
|
279
272
|
pagy (5.10.1)
|
280
273
|
activesupport
|
@@ -420,9 +413,8 @@ GEM
|
|
420
413
|
tzinfo (2.0.5)
|
421
414
|
concurrent-ruby (~> 1.0)
|
422
415
|
unicode-display_width (2.2.0)
|
423
|
-
view_component (2.
|
416
|
+
view_component (2.60.0)
|
424
417
|
activesupport (>= 5.0.0, < 8.0)
|
425
|
-
concurrent-ruby (~> 1.0)
|
426
418
|
method_source (~> 1.0)
|
427
419
|
warden (1.2.9)
|
428
420
|
rack (>= 2.0.9)
|
@@ -445,6 +437,7 @@ GEM
|
|
445
437
|
websocket-extensions (0.1.5)
|
446
438
|
xpath (3.2.0)
|
447
439
|
nokogiri (~> 1.8)
|
440
|
+
zeitwerk (2.6.0)
|
448
441
|
|
449
442
|
PLATFORMS
|
450
443
|
ruby
|
@@ -515,7 +508,7 @@ DEPENDENCIES
|
|
515
508
|
web-console (>= 3.3.0)
|
516
509
|
webdrivers
|
517
510
|
webmock
|
518
|
-
zeitwerk
|
511
|
+
zeitwerk (~> 2.3)
|
519
512
|
|
520
513
|
BUNDLED WITH
|
521
514
|
2.3.5
|
@@ -25,8 +25,10 @@
|
|
25
25
|
<% end %>
|
26
26
|
<% if body? %>
|
27
27
|
<div class="flex flex-col sm:flex-row space-y-4 sm:space-y-0 sm:gap-4 w-full">
|
28
|
-
<div class="
|
29
|
-
<%=
|
28
|
+
<div class="flex-1 overflow-auto <% if sidebar? %> w-2/3 <% end %>">
|
29
|
+
<div class="relative <%= white_panel_classes %> <%= @body_classes %>">
|
30
|
+
<%= body %>
|
31
|
+
</div>
|
30
32
|
</div>
|
31
33
|
<% if sidebar? %>
|
32
34
|
<div class="w-full sm:w-1/3 flex-shrink-0 h-full <%= white_panel_classes %>">
|
@@ -5,8 +5,6 @@ class Avo::PanelComponent < ViewComponent::Base
|
|
5
5
|
attr_reader :name
|
6
6
|
attr_reader :classes
|
7
7
|
|
8
|
-
delegate :white_panel_classes, to: :helpers
|
9
|
-
|
10
8
|
renders_one :tools
|
11
9
|
renders_one :body
|
12
10
|
renders_one :sidebar
|
@@ -28,6 +26,10 @@ class Avo::PanelComponent < ViewComponent::Base
|
|
28
26
|
|
29
27
|
private
|
30
28
|
|
29
|
+
def white_panel_classes
|
30
|
+
"bg-white rounded shadow"
|
31
|
+
end
|
32
|
+
|
31
33
|
def data_attributes
|
32
34
|
@data.merge({"panel-index": @index})
|
33
35
|
end
|
@@ -20,7 +20,7 @@
|
|
20
20
|
</div>
|
21
21
|
</div>
|
22
22
|
<% else %>
|
23
|
-
<div class="flex flex-wrap gap-2 p-2
|
23
|
+
<div class="flex flex-wrap gap-2 bg-white p-2" data-target="tab-switcher" data-style="pills">
|
24
24
|
<% visible_items.each do |tab| %>
|
25
25
|
<%= a_link tab_path(tab),
|
26
26
|
color: selected?(tab) ? :primary : :gray,
|
@@ -11,8 +11,6 @@ class Avo::TabSwitcherComponent < Avo::BaseComponent
|
|
11
11
|
attr_reader :view
|
12
12
|
attr_reader :style
|
13
13
|
|
14
|
-
delegate :white_panel_classes, to: :helpers
|
15
|
-
|
16
14
|
def initialize(resource:, group:, current_tab:, active_tab_name:, view:, style:)
|
17
15
|
@active_tab_name = active_tab_name
|
18
16
|
@resource = resource
|
@@ -1,11 +1,5 @@
|
|
1
1
|
module Avo
|
2
2
|
class ApplicationController < ::ActionController::Base
|
3
|
-
if defined?(Pundit::Authorization)
|
4
|
-
include Pundit::Authorization
|
5
|
-
else
|
6
|
-
include Pundit
|
7
|
-
end
|
8
|
-
|
9
3
|
include Pagy::Backend
|
10
4
|
include Avo::ApplicationHelper
|
11
5
|
include Avo::UrlHelpers
|
@@ -24,7 +18,7 @@ module Avo
|
|
24
18
|
before_action :set_view
|
25
19
|
before_action :set_sidebar_open
|
26
20
|
|
27
|
-
rescue_from
|
21
|
+
rescue_from Avo::NotAuthorizedError, with: :render_unauthorized
|
28
22
|
rescue_from ActiveRecord::RecordInvalid, with: :exception_logger
|
29
23
|
|
30
24
|
helper_method :_current_user, :resources_path, :resource_path, :new_resource_path, :edit_resource_path, :resource_attach_path, :resource_detach_path, :related_resources_path, :turbo_frame_request?, :resource_view_path
|
@@ -257,18 +251,16 @@ module Avo
|
|
257
251
|
instance_eval(&Avo.configuration.authenticate)
|
258
252
|
end
|
259
253
|
|
260
|
-
def render_unauthorized(
|
261
|
-
|
262
|
-
flash.now[:notice] = t "avo.not_authorized"
|
263
|
-
|
264
|
-
redirect_url = if request.referrer.blank? || (request.referrer == request.url)
|
265
|
-
root_url
|
266
|
-
else
|
267
|
-
request.referrer
|
268
|
-
end
|
254
|
+
def render_unauthorized(_exception)
|
255
|
+
flash.now[:notice] = t "avo.not_authorized"
|
269
256
|
|
270
|
-
|
257
|
+
redirect_url = if request.referrer.blank? || (request.referrer == request.url)
|
258
|
+
root_url
|
259
|
+
else
|
260
|
+
request.referrer
|
271
261
|
end
|
262
|
+
|
263
|
+
redirect_to(redirect_url)
|
272
264
|
end
|
273
265
|
|
274
266
|
def set_authorization
|
@@ -157,12 +157,9 @@ module Avo
|
|
157
157
|
private
|
158
158
|
|
159
159
|
def set_related_authorization
|
160
|
-
@
|
161
|
-
|
162
|
-
puts ["1->", t, related_resource].inspect
|
163
|
-
t
|
160
|
+
@related_authorization = if related_resource
|
161
|
+
related_resource.authorization(user: _current_user)
|
164
162
|
else
|
165
|
-
puts ["2->"].inspect
|
166
163
|
Services::AuthorizationService.new _current_user
|
167
164
|
end
|
168
165
|
end
|
data/avo.gemspec
CHANGED
@@ -34,13 +34,13 @@ Gem::Specification.new do |spec|
|
|
34
34
|
|
35
35
|
spec.add_dependency "rails", ">= 6.0"
|
36
36
|
spec.add_dependency "pagy"
|
37
|
-
|
37
|
+
spec.add_dependency "zeitwerk"
|
38
38
|
spec.add_dependency "countries"
|
39
39
|
spec.add_dependency "pundit"
|
40
40
|
spec.add_dependency "httparty"
|
41
41
|
spec.add_dependency "active_link_to"
|
42
42
|
spec.add_dependency "image_processing"
|
43
|
-
spec.add_dependency "view_component"
|
43
|
+
spec.add_dependency "view_component", "2.60"
|
44
44
|
spec.add_dependency "turbo-rails"
|
45
45
|
spec.add_dependency "addressable"
|
46
46
|
spec.add_dependency "meta-tags"
|
data/config/routes.rb
CHANGED
@@ -33,7 +33,7 @@ Avo::Engine.routes.draw do
|
|
33
33
|
|
34
34
|
# Generate resource routes as below:
|
35
35
|
# resources :posts
|
36
|
-
Avo::DynamicRouter.routes
|
36
|
+
Avo::DynamicRouter.routes(self)
|
37
37
|
|
38
38
|
# Associations
|
39
39
|
get "/:resource_name/:id/:related_name/new", to: "associations#new", as: "associations_new"
|
data/lib/avo/app.rb
CHANGED
@@ -17,12 +17,6 @@ module Avo
|
|
17
17
|
class_attribute :error_messages
|
18
18
|
|
19
19
|
class << self
|
20
|
-
def eager_load_resources
|
21
|
-
Rails.autoloaders.each do |loader|
|
22
|
-
loader.eager_load_dir(Rails.root.join("app", "avo", "resources").to_s)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
20
|
def boot
|
27
21
|
init_fields
|
28
22
|
|
data/lib/avo/configuration.rb
CHANGED
@@ -37,6 +37,7 @@ module Avo
|
|
37
37
|
attr_accessor :model_resource_mapping
|
38
38
|
attr_accessor :tabs_style
|
39
39
|
attr_accessor :resource_default_view
|
40
|
+
attr_accessor :authorization_client
|
40
41
|
attr_writer :branding
|
41
42
|
|
42
43
|
def initialize
|
@@ -85,6 +86,7 @@ module Avo
|
|
85
86
|
@model_resource_mapping = {}
|
86
87
|
@tabs_style = :tabs
|
87
88
|
@resource_default_view = :show
|
89
|
+
@authorization_client = nil
|
88
90
|
end
|
89
91
|
|
90
92
|
def current_user_method(&block)
|
data/lib/avo/dynamic_router.rb
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
module Avo
|
2
|
-
|
3
|
-
def self.routes
|
4
|
-
|
5
|
-
scope "resources", as: "resources" do
|
6
|
-
Avo::App.eager_load_resources
|
2
|
+
module DynamicRouter
|
3
|
+
def self.routes(router)
|
4
|
+
Rails.application.eager_load! unless Rails.env.production?
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
6
|
+
BaseResource.descendants
|
7
|
+
.select do |resource|
|
8
|
+
resource != :BaseResource
|
9
|
+
end
|
10
|
+
.select do |resource|
|
11
|
+
resource.is_a? Class
|
12
|
+
end
|
13
|
+
# .select do |resource|
|
14
|
+
# resource.model_class.present?
|
15
|
+
# end
|
16
|
+
.map do |resource|
|
17
|
+
router.resources resource.new.route_key
|
21
18
|
end
|
22
|
-
end
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
data/lib/avo/engine.rb
CHANGED
@@ -17,15 +17,6 @@ module Avo
|
|
17
17
|
::Avo::App.boot
|
18
18
|
end
|
19
19
|
|
20
|
-
# initializer "eager load resources" do |app|
|
21
|
-
# # puts ["app.root->", app.root.join('app', 'avo', 'resources')].inspect
|
22
|
-
# app.config.to_prepare do
|
23
|
-
# puts ["app.config.to_prepare->", app.root.join('app', 'avo', 'resources')].inspect
|
24
|
-
# Rails.autoloaders.main.eager_load_dir(app.root.join('app', 'avo', 'resources'))
|
25
|
-
# puts [".to_prepare BaseResource.descendants->", BaseResource.descendants].inspect
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
20
|
initializer "avo.autoload" do |app|
|
30
21
|
[
|
31
22
|
["app", "avo", "fields"],
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Avo
|
2
|
+
module Services
|
3
|
+
module AuthorizationClients
|
4
|
+
class PunditClient
|
5
|
+
def authorize(user, record, action, policy_class: nil)
|
6
|
+
Pundit.authorize(user, record, action, policy_class: policy_class)
|
7
|
+
rescue Pundit::NotDefinedError
|
8
|
+
raise NoPolicyError
|
9
|
+
rescue Pundit::NotAuthorizedError
|
10
|
+
raise NotAuthorizedError
|
11
|
+
end
|
12
|
+
|
13
|
+
def policy(user, record)
|
14
|
+
Pundit.policy(user, record)
|
15
|
+
end
|
16
|
+
|
17
|
+
def policy!(user, record)
|
18
|
+
Pundit.policy!(user, record)
|
19
|
+
rescue Pundit::NotDefinedError
|
20
|
+
raise NoPolicyError
|
21
|
+
end
|
22
|
+
|
23
|
+
def apply_policy(user, model, policy_class: nil)
|
24
|
+
# Try and figure out the scope from a given policy or auto-detected one
|
25
|
+
scope_from_policy_class = scope_for_policy_class(policy_class)
|
26
|
+
|
27
|
+
# If we discover one use it.
|
28
|
+
# Else fallback to pundit.
|
29
|
+
if scope_from_policy_class.present?
|
30
|
+
scope_from_policy_class.new(user, model).resolve
|
31
|
+
else
|
32
|
+
Pundit.policy_scope!(user, model)
|
33
|
+
end
|
34
|
+
rescue Pundit::NotDefinedError => error
|
35
|
+
raise NoPolicyError
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# Fetches the scope for a given policy
|
41
|
+
def scope_for_policy_class(policy_class = nil)
|
42
|
+
return if policy_class.blank?
|
43
|
+
|
44
|
+
if policy_class.present? && defined?(policy_class::Scope)
|
45
|
+
policy_class::Scope
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -3,29 +3,30 @@ module Avo
|
|
3
3
|
class AuthorizationService
|
4
4
|
attr_accessor :user
|
5
5
|
attr_accessor :record
|
6
|
+
attr_accessor :policy_class
|
6
7
|
|
7
8
|
class << self
|
9
|
+
def client
|
10
|
+
(configuration_client || default_client).new
|
11
|
+
end
|
12
|
+
|
8
13
|
def authorize(user, record, action, policy_class: nil, **args)
|
9
14
|
return true if skip_authorization
|
10
15
|
return true if user.nil?
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
false
|
26
|
-
else
|
27
|
-
raise error
|
28
|
-
end
|
17
|
+
client.authorize user, record, action, policy_class: policy_class
|
18
|
+
|
19
|
+
true
|
20
|
+
rescue NoPolicyError => error
|
21
|
+
# By default, Avo allows anything if you don't have a policy present.
|
22
|
+
return true unless Avo.configuration.raise_error_on_missing_policy
|
23
|
+
|
24
|
+
raise error
|
25
|
+
rescue => error
|
26
|
+
if args[:raise_exception] == false
|
27
|
+
false
|
28
|
+
else
|
29
|
+
raise error
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -35,7 +36,7 @@ module Avo
|
|
35
36
|
# If no action passed we should raise error if the user wants that.
|
36
37
|
# If not, just allow it.
|
37
38
|
if action.nil?
|
38
|
-
raise
|
39
|
+
raise NoPolicyError.new "Policy method is missing" if Avo.configuration.raise_error_on_missing_policy
|
39
40
|
|
40
41
|
return true
|
41
42
|
end
|
@@ -48,44 +49,27 @@ module Avo
|
|
48
49
|
def apply_policy(user, model, policy_class: nil)
|
49
50
|
return model if skip_authorization || user.nil?
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
# Else fallback to pundit.
|
57
|
-
if scope_from_policy_class.present?
|
58
|
-
scope_from_policy_class.new(user, model).resolve
|
59
|
-
else
|
60
|
-
Pundit.policy_scope!(user, model)
|
61
|
-
end
|
62
|
-
rescue Pundit::NotDefinedError => e
|
63
|
-
return model unless Avo.configuration.raise_error_on_missing_policy
|
64
|
-
|
65
|
-
raise e
|
66
|
-
end
|
52
|
+
client.apply_policy(user, model, policy_class: policy_class)
|
53
|
+
rescue NoPolicyError => error
|
54
|
+
return model unless Avo.configuration.raise_error_on_missing_policy
|
55
|
+
|
56
|
+
raise error
|
67
57
|
end
|
68
58
|
|
69
59
|
def skip_authorization
|
70
60
|
Avo::App.license.lacks_with_trial :authorization
|
71
61
|
end
|
72
62
|
|
73
|
-
def authorized_methods(user, record)
|
74
|
-
[:new, :edit, :update, :show, :destroy].map do |method|
|
75
|
-
[method, authorize(user, record, Avo.configuration.authorization_methods[method])]
|
76
|
-
end.to_h
|
77
|
-
end
|
78
|
-
|
79
63
|
def defined_methods(user, record, policy_class: nil, **args)
|
80
|
-
return
|
64
|
+
return client.policy!(user, record).methods if policy_class.nil?
|
81
65
|
|
82
66
|
# I'm aware this will not raise a Pundit error.
|
83
67
|
# Should the policy not exist, it will however raise an uninitialized constant error, which is probably what we want when specifying a custom policy
|
84
68
|
policy_class.new(user, record).methods
|
85
|
-
rescue
|
69
|
+
rescue NoPolicyError => error
|
86
70
|
return [] unless Avo.configuration.raise_error_on_missing_policy
|
87
71
|
|
88
|
-
raise
|
72
|
+
raise error
|
89
73
|
rescue => error
|
90
74
|
if args[:raise_exception] == false
|
91
75
|
[]
|
@@ -94,24 +78,27 @@ module Avo
|
|
94
78
|
end
|
95
79
|
end
|
96
80
|
|
97
|
-
|
98
|
-
|
99
|
-
return if policy_class.blank?
|
81
|
+
def configuration_client
|
82
|
+
client = Avo.configuration.authorization_client
|
100
83
|
|
101
|
-
if
|
102
|
-
|
84
|
+
return if client.blank?
|
85
|
+
|
86
|
+
if client.is_a?(String)
|
87
|
+
client.safe_constantize
|
88
|
+
else
|
89
|
+
client
|
103
90
|
end
|
104
91
|
end
|
92
|
+
|
93
|
+
def default_client
|
94
|
+
Avo::Services::AuthorizationClients::PunditClient
|
95
|
+
end
|
105
96
|
end
|
106
97
|
|
107
98
|
def initialize(user = nil, record = nil, policy_class: nil)
|
108
99
|
@user = user
|
109
100
|
@record = record
|
110
|
-
@policy_class = policy_class ||
|
111
|
-
end
|
112
|
-
|
113
|
-
def authorize(action, **args)
|
114
|
-
self.class.authorize(user, record, action, policy_class: @policy_class, **args)
|
101
|
+
@policy_class = policy_class || self.class.client.policy(user, record)&.class
|
115
102
|
end
|
116
103
|
|
117
104
|
def set_record(record)
|
@@ -120,22 +107,16 @@ module Avo
|
|
120
107
|
self
|
121
108
|
end
|
122
109
|
|
123
|
-
def set_user(user)
|
124
|
-
@user = user
|
125
|
-
|
126
|
-
self
|
127
|
-
end
|
128
|
-
|
129
110
|
def authorize_action(action, **args)
|
130
|
-
self.class.authorize_action(user, record, action, policy_class:
|
111
|
+
self.class.authorize_action(user, record, action, policy_class: policy_class, **args)
|
131
112
|
end
|
132
113
|
|
133
114
|
def apply_policy(model)
|
134
|
-
self.class.apply_policy(user, model, policy_class:
|
115
|
+
self.class.apply_policy(user, model, policy_class: policy_class)
|
135
116
|
end
|
136
117
|
|
137
118
|
def defined_methods(model, **args)
|
138
|
-
self.class.defined_methods(user, model, policy_class:
|
119
|
+
self.class.defined_methods(user, model, policy_class: policy_class, **args)
|
139
120
|
end
|
140
121
|
|
141
122
|
def has_method?(method, **args)
|
data/lib/avo/version.rb
CHANGED
data/lib/avo.rb
CHANGED
@@ -44,6 +44,10 @@ module Avo
|
|
44
44
|
class LicenseVerificationTemperedError < StandardError; end
|
45
45
|
|
46
46
|
class LicenseInvalidError < StandardError; end
|
47
|
+
|
48
|
+
class NotAuthorizedError < StandardError; end
|
49
|
+
|
50
|
+
class NoPolicyError < StandardError; end
|
47
51
|
end
|
48
52
|
|
49
53
|
loader.eager_load
|
@@ -13,7 +13,7 @@ nb:
|
|
13
13
|
attachment_class_attached: "%{attachment_class} lagt til."
|
14
14
|
attachment_class_detached: "%{attachment_class} fjernet."
|
15
15
|
attachment_destroyed: Vedlett slettet
|
16
|
-
cancel:
|
16
|
+
cancel: Avslutt
|
17
17
|
choose_a_country: Velg et land
|
18
18
|
choose_an_option: Velg et alternativ
|
19
19
|
choose_item: Velge %{item}
|
@@ -3,7 +3,7 @@ nn:
|
|
3
3
|
avo:
|
4
4
|
action_ran_successfully: Suksess!
|
5
5
|
actions: Handlingar
|
6
|
-
and_x_other_resources: og %{count} andre
|
6
|
+
and_x_other_resources: og %{count} andre ressurar
|
7
7
|
are_you_sure: Er du sikker?
|
8
8
|
are_you_sure_detach_item: Er du sikker på at du vil koble frå %{item}.
|
9
9
|
are_you_sure_you_want_to_run_this_option: Er du sikker?
|
@@ -13,7 +13,7 @@ nn:
|
|
13
13
|
attachment_class_attached: "%{attachment_class} lagt til."
|
14
14
|
attachment_class_detached: "%{attachment_class} fjerna."
|
15
15
|
attachment_destroyed: Vedlegg sletta
|
16
|
-
cancel:
|
16
|
+
cancel: Avslutt
|
17
17
|
choose_a_country: Vel eit land
|
18
18
|
choose_an_option: Vel eit alternativ
|
19
19
|
choose_item: Vel %{item}
|
@@ -56,7 +56,7 @@ nn:
|
|
56
56
|
delete_row: Slett rad
|
57
57
|
key: Nøkkel
|
58
58
|
value: Verdi
|
59
|
-
list_is_empty:
|
59
|
+
list_is_empty: Listen er tom
|
60
60
|
loading: Lastar
|
61
61
|
more: Meir
|
62
62
|
new: ny
|
@@ -75,17 +75,17 @@ nn:
|
|
75
75
|
higher: Flytt elementet opp
|
76
76
|
lower: Flytt elementet ned
|
77
77
|
reorder_record: Sorter element
|
78
|
-
to_bottom: Flytt elementet til
|
78
|
+
to_bottom: Flytt elementet til bunnen
|
79
79
|
to_top: Flytt elementet til toppen
|
80
80
|
per_page: Per side
|
81
|
-
prev_page:
|
81
|
+
prev_page: Forrige side
|
82
82
|
remove_selection: Fjern val
|
83
83
|
reset_filters: Nullstill filter
|
84
84
|
resource_created: Ressurs generert
|
85
85
|
resource_destroyed: Ressurs sletta
|
86
86
|
resource_translations:
|
87
87
|
user:
|
88
|
-
one:
|
88
|
+
one: bruker
|
89
89
|
other: brukarar
|
90
90
|
zero: brukarar
|
91
91
|
resource_updated: Ressurs oppdatert
|
@@ -111,7 +111,7 @@ nn:
|
|
111
111
|
was_successfully_created: vart oppretta
|
112
112
|
was_successfully_updated: vart oppdatert
|
113
113
|
x_items_more:
|
114
|
-
one:
|
114
|
+
one: ett element til
|
115
115
|
other: "%{count} fleire element"
|
116
116
|
zero: ingen fleire element
|
117
117
|
x_records_selected_from_a_total_of_x_html: <span class="font-bold text-gray-700">%{selected}</span> valde postar på denne sida av totalt <span class="font-bold text-gray-700">%{count}</span>
|
@@ -8060,12 +8060,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
8060
8060
|
opacity:1
|
8061
8061
|
}
|
8062
8062
|
|
8063
|
-
.shadow-md{
|
8064
|
-
--tw-shadow:0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
8065
|
-
--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
|
8066
|
-
box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
|
8067
|
-
}
|
8068
|
-
|
8069
8063
|
.shadow-panel{
|
8070
8064
|
--tw-shadow:0px 4px 8px rgba(0, 0, 0, 0.04), 0px 0px 2px rgba(0, 0, 0, 0.06), 0px 0px 1px rgba(0, 0, 0, 0.04);
|
8071
8065
|
--tw-shadow-colored:0px 4px 8px var(--tw-shadow-color), 0px 0px 2px var(--tw-shadow-color), 0px 0px 1px var(--tw-shadow-color);
|
@@ -8084,18 +8078,18 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
8084
8078
|
box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
|
8085
8079
|
}
|
8086
8080
|
|
8087
|
-
.shadow-context{
|
8088
|
-
--tw-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 0 25px -5px rgba(0, 0, 0, 0.1);
|
8089
|
-
--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color), 0 0 25px -5px var(--tw-shadow-color);
|
8090
|
-
box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
|
8091
|
-
}
|
8092
|
-
|
8093
8081
|
.shadow{
|
8094
8082
|
--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
8095
8083
|
--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
8096
8084
|
box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
|
8097
8085
|
}
|
8098
8086
|
|
8087
|
+
.shadow-context{
|
8088
|
+
--tw-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 0 25px -5px rgba(0, 0, 0, 0.1);
|
8089
|
+
--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color), 0 0 25px -5px var(--tw-shadow-color);
|
8090
|
+
box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
|
8091
|
+
}
|
8092
|
+
|
8099
8093
|
.outline-none{
|
8100
8094
|
outline:2px solid transparent;
|
8101
8095
|
outline-offset:2px
|
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.17.1.pre.
|
4
|
+
version: 2.17.1.pre.2.customauthorizationclients
|
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-
|
12
|
+
date: 2022-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: zeitwerk
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: countries
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,16 +127,16 @@ dependencies:
|
|
113
127
|
name: view_component
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
|
-
- -
|
130
|
+
- - '='
|
117
131
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
132
|
+
version: '2.60'
|
119
133
|
type: :runtime
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
|
-
- -
|
137
|
+
- - '='
|
124
138
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
139
|
+
version: '2.60'
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: turbo-rails
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1848,6 +1862,7 @@ files:
|
|
1848
1862
|
- lib/avo/resources/controls/execution_context.rb
|
1849
1863
|
- lib/avo/resources/controls/items_holder.rb
|
1850
1864
|
- lib/avo/resources/controls/link_to.rb
|
1865
|
+
- lib/avo/services/authorization_clients/pundit_client.rb
|
1851
1866
|
- lib/avo/services/authorization_service.rb
|
1852
1867
|
- lib/avo/services/encryption_service.rb
|
1853
1868
|
- lib/avo/services/uri_service.rb
|