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 +5 -5
- data/.circleci/config.yml +3 -11
- data/.ruby-version +1 -1
- data/Appraisals +18 -23
- data/Gemfile +3 -1
- data/declarative_authorization.gemspec +1 -1
- data/lib/declarative_authorization/controller/grape.rb +15 -4
- data/lib/declarative_authorization/controller_permission.rb +1 -5
- data/lib/declarative_authorization/test/helpers.rb +8 -2
- data/lib/declarative_authorization/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 719562dc167a376019c1cbf5ef98fd3156bbd0420345b49499fb4e2932f7760b
|
4
|
+
data.tar.gz: 5e730141340ca6205f1c43616c0e4585fb203d3f992848911a778433c01b7da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 954e5d140855c4db4c1be63431e64357bcb1c2a3cdf54fd36bd2ecdd3b45bbf75315da5ca6762af8cab7d6cb582831f5b57e0e57d87e7b9bb05ebbf4c065017c
|
7
|
+
data.tar.gz: 15132703089d3c1b7c84a474dbf5d3445c21d41580e128c7120bc6a6a3ae184a5c2945b397417463a3c4190ad17453dca442e8c37d93685629179c879cbc7d9c
|
data/.circleci/config.yml
CHANGED
@@ -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-
|
17
|
+
test-ruby-263:
|
24
18
|
docker:
|
25
|
-
- image: circleci/ruby:2.6.
|
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-
|
28
|
+
- test-ruby-263:
|
37
29
|
context: appfolio_test_context
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.6.3
|
data/Appraisals
CHANGED
@@ -1,31 +1,26 @@
|
|
1
|
-
|
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
|
-
|
4
|
+
case RUBY_VERSION
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
159
|
-
|
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/ ||
|
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.
|
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:
|
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: '
|
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: '
|
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
|
-
|
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
|