Skip to content

Commit

Permalink
implicit authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Oct 3, 2024
1 parent 28f324f commit 5e84d00
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/avo/associations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def authorize_if_defined(method, record = @record)

if @authorization.has_method?(method.to_sym)
@authorization.authorize_action method.to_sym
elsif Avo.configuration.authorization_client.present? && Avo.configuration.whitelisting_authorization
elsif Avo.configuration.authorization_client.present? && Avo.configuration.implicit_authorization
raise Avo::NotAuthorizedError.new
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/concerns/checks_assoc_authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def authorize_association_for(policy_method)
if service.has_method?(method_name, raise_exception: false)
service.authorize_action(method_name, record:, raise_exception: false)
else
!Avo.configuration.whitelisting_authorization
!Avo.configuration.implicit_authorization
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/avo/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Configuration
attr_accessor :default_view_type
attr_accessor :license_key
attr_accessor :authorization_methods
attr_accessor :whitelisting_authorization
attr_accessor :implicit_authorization
attr_accessor :authenticate
attr_accessor :current_user
attr_accessor :id_links_to_resource
Expand Down Expand Up @@ -69,7 +69,7 @@ def initialize
@license_key = nil
@current_user = proc {}
@authenticate = proc {}
@whitelisting_authorization = false
@implicit_authorization = false
@authorization_methods = {
index: "index?",
show: "show?",
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/fields/has_base_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def authorized?
if service.has_method? method
service.authorize_action(method, raise_exception: false)
else
!Avo.configuration.whitelisting_authorization
!Avo.configuration.implicit_authorization
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/avo/templates/initializer/avo.tt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Avo.configure do |config|
# }
# config.raise_error_on_missing_policy = false
config.authorization_client = nil
config.whitelisting_authorization = true
config.implicit_authorization = true

## == Localization ==
# config.locale = 'en-US'
Expand Down

0 comments on commit 5e84d00

Please sign in to comment.