ae_declarative_authorization 1.4.0 → 1.5.0

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: 58d5ae47fcb1b37a3bc09ff1f327c5b4bc1c17e0e10dfb41abe7b320d05455df
4
- data.tar.gz: eedc2584682aa79790b12236a070d14799e85102706db150239c58f460a962d7
3
+ metadata.gz: 5e11a2b5e7153658db82ba4882cf04c2dc4f7e1ec22d21908365af7a860de466
4
+ data.tar.gz: 01cc82ce6c960d11af9199fa142334de736b7957fd8b30dd81a95822964bca64
5
5
  SHA512:
6
- metadata.gz: 3610179d19f7119d9639a7b3c4423bcc2230c5298f88c1de8ffa8bd66d5213a276fabe6162a68deec057c8457b3b094cb221703617fe841a6bd134672ae9ed8b
7
- data.tar.gz: 1354377a7af061f622fba2970f327d24e725f418738bc9294580237a72201157eb5a9ef4cc4eac183b24d3278cbcd7049fbfc387adc58dc74e17741bf7fc2ea5
6
+ metadata.gz: c9c061d3055fdf6d84d81699a53e653e67bb42f6162dd4c27eac31e473d145e9cb14268cbe886114ba781428aafd179be2ea9449ba7b9e79ddbc4c2dfd3f6734
7
+ data.tar.gz: 708873a0ad5ab828bb8615d211b41d5a80cab0af1e4b7a985be167ef61267a6eba1add3f63b059677c5c9c212a31c891739c7200ab321b64e32bb2e0c9d8655b
@@ -1,3 +1,3 @@
1
1
  module DeclarativeAuthorization
2
- VERSION = '1.4.0'.freeze
2
+ VERSION = '1.5.0'.freeze
3
3
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module DeclAuth
6
+ # Enforces placing all `before_action` statements prior to the first `filter_access_to` statement.
7
+ # This ensures that any data required by the access filters is available before the filter is applied.
8
+ # See the documentation above the `filter_access_to` method in Authorization::Controller::DSL for more information
9
+ #
10
+ # @example
11
+ # # bad
12
+ # before_action: :do_something
13
+ # filter_access_to :all
14
+ # before_action :find_object
15
+ #
16
+ # # good
17
+ # before_action: :do_something
18
+ # before_action :find_object
19
+ #
20
+ # filter_access_to :all
21
+ #
22
+ class BeforeActionsPrecedeAccessFilter < RuboCop::Cop::Base
23
+ def_node_search :before_actions, '(send nil? :before_action ...)'
24
+ def_node_search :access_filters, '(send nil? :filter_access_to ...)'
25
+
26
+ MSG = '`:filter_access_to` statements should be placed after all other `:before_action` statements.'
27
+
28
+ def on_class(node)
29
+ before_actions = before_actions(node)
30
+ access_filters = access_filters(node)
31
+
32
+ return if before_actions.count.zero? || access_filters.count.zero?
33
+
34
+ last_before_action = before_actions.to_a.last
35
+ first_access_filter = access_filters.to_a.first
36
+
37
+ return if last_before_action.sibling_index < first_access_filter.sibling_index
38
+
39
+ add_offense(access_filters.first, message: MSG)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_declarative_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-10-01 00:00:00.000000000 Z
10
+ date: 2025-01-17 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: blockenspiel
@@ -77,13 +76,13 @@ files:
77
76
  - lib/generators/authorization/install/install_generator.rb
78
77
  - lib/generators/authorization/rules/rules_generator.rb
79
78
  - lib/generators/authorization/rules/templates/authorization_rules.rb
79
+ - lib/rubocop/cop/decl_auth/before_actions_precede_access_filter.rb
80
80
  - lib/tasks/authorization_tasks.rake
81
81
  homepage: https://github.com/appfolio/ae_declarative_authorization
82
82
  licenses:
83
83
  - MIT
84
84
  metadata:
85
85
  allowed_push_host: https://rubygems.org
86
- post_install_message:
87
86
  rdoc_options: []
88
87
  require_paths:
89
88
  - lib
@@ -98,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
97
  - !ruby/object:Gem::Version
99
98
  version: '0'
100
99
  requirements: []
101
- rubygems_version: 3.5.7
102
- signing_key:
100
+ rubygems_version: 3.6.3
103
101
  specification_version: 4
104
102
  summary: Rails gem for maintainable authorization based on readable authorization
105
103
  rules.