ae_declarative_authorization 0.10.2 → 0.12.1

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
- SHA1:
3
- metadata.gz: 380a434297fb196dcfbf059509ee1a50cd7835d2
4
- data.tar.gz: db8af9fcb8906a699ba3a2e602d7a83446772074
2
+ SHA256:
3
+ metadata.gz: 719562dc167a376019c1cbf5ef98fd3156bbd0420345b49499fb4e2932f7760b
4
+ data.tar.gz: 5e730141340ca6205f1c43616c0e4585fb203d3f992848911a778433c01b7da9
5
5
  SHA512:
6
- metadata.gz: fdf1b43b12a93c790af306c1a4c1158f6e7c6205bba57c0b39582481b7f2314d57c69893fef313871929e63c943211cde5d2a07a9f9ec5495f8f2da87f0fb12d
7
- data.tar.gz: 4241e224613130471ea25351cc5b50204d1730f6986a8aa17302905ac17599b373a5df59ef5a51ad18cb116df109ae71dce7adcb6e488ec4ed53b4bf1dae7be4
6
+ metadata.gz: 954e5d140855c4db4c1be63431e64357bcb1c2a3cdf54fd36bd2ecdd3b45bbf75315da5ca6762af8cab7d6cb582831f5b57e0e57d87e7b9bb05ebbf4c065017c
7
+ data.tar.gz: 15132703089d3c1b7c84a474dbf5d3445c21d41580e128c7120bc6a6a3ae184a5c2945b397417463a3c4190ad17453dca442e8c37d93685629179c879cbc7d9c
@@ -8,30 +8,22 @@ commands:
8
8
  - run: bundle exec appraisal rake test
9
9
 
10
10
  jobs:
11
- test-ruby-233:
12
- docker:
13
- - image: circleci/ruby:2.3.3
14
- steps:
15
- - bundle_install_and_test
16
-
17
11
  test-ruby-253:
18
12
  docker:
19
13
  - image: circleci/ruby:2.5.3
20
14
  steps:
21
15
  - bundle_install_and_test
22
16
 
23
- test-ruby-262:
17
+ test-ruby-263:
24
18
  docker:
25
- - image: circleci/ruby:2.6.2
19
+ - image: circleci/ruby:2.6.3
26
20
  steps:
27
21
  - bundle_install_and_test
28
22
 
29
23
  workflows:
30
24
  rc:
31
25
  jobs:
32
- - test-ruby-233:
33
- context: appfolio_test_context
34
26
  - test-ruby-253:
35
27
  context: appfolio_test_context
36
- - test-ruby-262:
28
+ - test-ruby-263:
37
29
  context: appfolio_test_context
@@ -1 +1 @@
1
- ruby-2.3.3
1
+ ruby-2.6.3
data/Appraisals CHANGED
@@ -1,31 +1,26 @@
1
- case RUBY_VERSION
1
+ RAILS_VERSIONS = ['5.2.2.1', '6.0.2.1']
2
+ GRAPE_VERSIONS = ['1.1.0', '1.2.3', '1.3.0']
2
3
 
3
- when '2.3.3', '2.5.3', '2.6.2' then
4
+ case RUBY_VERSION
4
5
 
5
- appraise "ruby-#{RUBY_VERSION}-rails507" do
6
- gem 'rails', '5.0.7'
7
- gem 'grape', '1.1.0'
8
- gem 'rails-controller-testing'
9
- end
6
+ when '2.5.3', '2.6.3' then
7
+ RAILS_VERSIONS.product(GRAPE_VERSIONS).each do |rails_version, grape_version|
8
+ appraise "ruby-#{RUBY_VERSION}-rails#{rails_version}-grape#{grape_version}" do
9
+ gem 'rails', rails_version
10
+ gem 'grape', grape_version
10
11
 
11
- appraise "ruby-#{RUBY_VERSION}-rails516" do
12
- gem 'rails', '5.1.6'
13
- gem 'grape', '1.2.3'
14
- gem 'rails-controller-testing'
15
- end
12
+ if Gem::Version.new(grape_version) < Gem::Version.new('1.3.0')
13
+ # https://github.com/ruby-grape/grape/pull/1956
14
+ gem "rack", "< 2.1.0"
15
+ end
16
16
 
17
- appraise "ruby-#{RUBY_VERSION}-rails521" do
18
- gem 'rails', '5.2.1'
19
- gem 'grape', '1.2.3'
20
- gem 'rails-controller-testing'
17
+ if Gem::Version.new(rails_version) >= Gem::Version.new('6')
18
+ gem 'sqlite3', '~> 1.4'
19
+ else
20
+ gem 'sqlite3', '~> 1.3.0'
21
+ end
22
+ end
21
23
  end
22
-
23
- appraise "ruby-#{RUBY_VERSION}-rails522" do
24
- gem 'rails', '5.2.2'
25
- gem 'grape', '1.2.3'
26
- gem 'rails-controller-testing'
27
- end
28
-
29
24
  else
30
25
  raise "Unsupported Ruby version #{RUBY_VERSION}"
31
26
 
data/Gemfile CHANGED
@@ -4,4 +4,6 @@ gemspec
4
4
 
5
5
  gem 'appraisal', '~> 2.1'
6
6
  gem 'mocha', '~> 1.0', require: false
7
- gem 'sqlite3', '~> 1.3.0'
7
+ gem 'sprockets', '< 4'
8
+
9
+ gem 'rails-controller-testing'
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
  s.add_dependency(%q<blockenspiel>, ['~> 0.5.0'])
23
- s.add_dependency(%q<rails>, ['>= 4.2.5.2', '< 6'])
23
+ s.add_dependency(%q<rails>, ['>= 4.2.5.2', '< 7'])
24
24
  end
@@ -37,6 +37,12 @@ module Authorization
37
37
  end
38
38
 
39
39
  def filter_access_filter # :nodoc:
40
+ begin
41
+ route
42
+ rescue
43
+ # Acceessing route raises an exception when the response is a 405 MethodNotAllowed
44
+ return
45
+ end
40
46
  unless allowed?("#{request.request_method} #{route.origin}")
41
47
  if respond_to?(:permission_denied, true)
42
48
  # permission_denied needs to render or redirect
@@ -51,13 +57,18 @@ module Authorization
51
57
  ::Rails.logger
52
58
  end
53
59
 
54
- protected
55
-
56
60
  def api_class
57
61
  if options[:for].respond_to?(:base)
58
- options[:for].base # Grape >= 1.2.0 controller
62
+ # Grape >= 1.2.0 endpoint
63
+ # Authorization::Controller::Grape can be included into either Grape::API
64
+ # or Grape::API::Instance, so we need to check both.
65
+ [
66
+ options[:for],
67
+ options[:for].base
68
+ ].detect { |api| api.respond_to?(:decl_auth_context) }
59
69
  else
60
- options[:for] # Grape < 1.2.0 controller
70
+ # Grape < 1.2.0 endpoint
71
+ options[:for]
61
72
  end
62
73
  end
63
74
  end
@@ -68,11 +68,7 @@ module Authorization
68
68
 
69
69
  def controller_class(contr)
70
70
  if defined?(Grape) && contr.class < Grape::Endpoint
71
- if contr.options[:for].respond_to?(:base)
72
- contr.options[:for].base # Grape >= 1.2.0 controller
73
- else
74
- contr.options[:for] # Grape < 1.2.0 controller
75
- end
71
+ contr.api_class
76
72
  else
77
73
  contr.class # Rails controller
78
74
  end
@@ -155,8 +155,14 @@ module DeclarativeAuthorization
155
155
  alias :access_tests_not_required :this_is_an_abstract_controller_so_it_needs_no_access_tests
156
156
 
157
157
  def all_public_actions
158
- actions = controller_class.public_instance_methods(false)
159
- actions += controller_class.superclass.public_instance_methods(false)
158
+ actions = []
159
+ if defined?(Grape) && [Grape::API, Grape::API::Instance].any? { |base| controller_class < base }
160
+ actions += controller_class.routes.map { |api| "#{api.request_method} #{api.origin}" }
161
+ else
162
+ actions += controller_class.public_instance_methods(false)
163
+ actions += controller_class.superclass.public_instance_methods(false)
164
+ end
165
+
160
166
  actions.reject! do |method|
161
167
  method =~ /^_/ ||
162
168
  method =~ /^rescue_action/ ||
@@ -1,3 +1,3 @@
1
1
  module DeclarativeAuthorization
2
- VERSION = '0.10.2'.freeze
2
+ VERSION = '0.12.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_declarative_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-18 00:00:00.000000000 Z
12
+ date: 2020-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: blockenspiel
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: 4.2.5.2
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
- version: '6'
37
+ version: '7'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 4.2.5.2
45
45
  - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '6'
47
+ version: '7'
48
48
  description: ae_declarative_authorization is a Rails gem for maintainable authorization
49
49
  based on readable authorization rules.
50
50
  email: dev@appfolio.com
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.5.2
106
+ rubygems_version: 3.1.4
108
107
  signing_key:
109
108
  specification_version: 4
110
109
  summary: ae_declarative_authorization is a Rails gem for maintainable authorization