consul 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/.travis.yml +2 -3
- data/CHANGELOG.md +39 -0
- data/Gemfile +1 -1
- data/Gemfile.3-2.lock +2 -2
- data/Gemfile.4-2.lock +2 -2
- data/Gemfile.5-2 +1 -0
- data/Gemfile.5-2.lock +3 -1
- data/Gemfile.6-0 +1 -1
- data/Gemfile.6-0.lock +66 -65
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/consul/controller.rb +25 -54
- data/lib/consul/spec/matchers.rb +1 -1
- data/lib/consul/util.rb +30 -0
- data/lib/consul/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 49583154c64138e64a0fa47a0e85be855a0a54b05e906ca5ca0da4e6fa39ee16
|
4
|
+
data.tar.gz: 149f14959bc7e8ef2a3dc90a9d446f4840229d1f022f164534f23b099275ac6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3877afeee641f47702f2951e9b1609220b96c85df245d2a0a0f91c301823fce9e878a8b7e39d8b90f34a7104dd4ce8c3027afa41c76731003ae0ab137fbbb991
|
7
|
+
data.tar.gz: d96bf2a79ef26bf7e8567b02bb306d76f8d1314fd1ba0179ad85f1a0fd51cbaecb573365dd645815d4b82445a92ea030fd29786c2eff67c33238e8c770510284
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,45 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
13
13
|
|
14
14
|
-
|
15
15
|
|
16
|
+
|
17
|
+
## 1.0.3 - 2019-09-23
|
18
|
+
|
19
|
+
### Security fix
|
20
|
+
|
21
|
+
This releases fix a security issue where in a controller with multiple `power` directives, the `:only` and `:except` options of the last directive was applied to all directives.
|
22
|
+
|
23
|
+
Affected code looks like this:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
class UsersController < ApplicationController
|
27
|
+
power :foo
|
28
|
+
power :bar, only: :index
|
29
|
+
|
30
|
+
...
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
In this example both the powers `:foo` and `:bar` were only checked for the `#index` action. Other actions were left unprotected by powers checks.
|
35
|
+
|
36
|
+
Controllers with a single `power` directive are unaffected.
|
37
|
+
Contollers where neither `power` uses `:only` or `:except` options are unaffected.
|
38
|
+
|
39
|
+
This vulnerability has been assigned the CVE identifier CVE-2019-16377.
|
40
|
+
|
41
|
+
|
42
|
+
### Compatible changes
|
43
|
+
|
44
|
+
- The RSpec matcher `check_power` now also sees powers inherited by a parent controller.
|
45
|
+
|
46
|
+
|
47
|
+
## 1.0.2 - 2019-05-22
|
48
|
+
|
49
|
+
### Compatible changes
|
50
|
+
|
51
|
+
- The `#arity` of power methods with optional arguments is now preserved.
|
52
|
+
|
53
|
+
|
54
|
+
|
16
55
|
## 1.0.1 - 2019-02-27
|
17
56
|
|
18
57
|
### Compatible changes
|
data/Gemfile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Gemfile.5-2
|
1
|
+
./Gemfile.5-2
|
data/Gemfile.3-2.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consul (1.0.
|
4
|
+
consul (1.0.3)
|
5
5
|
edge_rider (>= 0.3.0)
|
6
6
|
memoized (>= 1.0.2)
|
7
7
|
rails (>= 3.2)
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
concurrent-ruby (1.1.4)
|
46
46
|
database_cleaner (1.4.1)
|
47
47
|
diff-lcs (1.3)
|
48
|
-
edge_rider (0.
|
48
|
+
edge_rider (1.0.0)
|
49
49
|
activerecord
|
50
50
|
erubis (2.7.0)
|
51
51
|
gemika (0.3.4)
|
data/Gemfile.4-2.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consul (1.0.
|
4
|
+
consul (1.0.3)
|
5
5
|
edge_rider (>= 0.3.0)
|
6
6
|
memoized (>= 1.0.2)
|
7
7
|
rails (>= 3.2)
|
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
crass (1.0.4)
|
52
52
|
database_cleaner (1.7.0)
|
53
53
|
diff-lcs (1.2.5)
|
54
|
-
edge_rider (0.
|
54
|
+
edge_rider (1.0.0)
|
55
55
|
activerecord
|
56
56
|
erubis (2.7.0)
|
57
57
|
gemika (0.3.4)
|
data/Gemfile.5-2
CHANGED
data/Gemfile.5-2.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consul (1.0.
|
4
|
+
consul (1.0.3)
|
5
5
|
edge_rider (>= 0.3.0)
|
6
6
|
memoized (>= 1.0.2)
|
7
7
|
rails (>= 3.2)
|
@@ -54,6 +54,7 @@ GEM
|
|
54
54
|
assignable_values (0.12.1)
|
55
55
|
activerecord (>= 2.3)
|
56
56
|
builder (3.2.3)
|
57
|
+
byebug (11.0.1)
|
57
58
|
concurrent-ruby (1.1.4)
|
58
59
|
crass (1.0.4)
|
59
60
|
database_cleaner (1.7.0)
|
@@ -159,6 +160,7 @@ PLATFORMS
|
|
159
160
|
|
160
161
|
DEPENDENCIES
|
161
162
|
assignable_values
|
163
|
+
byebug
|
162
164
|
consul!
|
163
165
|
database_cleaner
|
164
166
|
gemika
|
data/Gemfile.6-0
CHANGED
data/Gemfile.6-0.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consul (1.0.
|
4
|
+
consul (1.0.2)
|
5
5
|
edge_rider (>= 0.3.0)
|
6
6
|
memoized (>= 1.0.2)
|
7
7
|
rails (>= 3.2)
|
@@ -9,68 +9,69 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actioncable (6.0.0
|
13
|
-
actionpack (= 6.0.0
|
12
|
+
actioncable (6.0.0)
|
13
|
+
actionpack (= 6.0.0)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (6.0.0
|
17
|
-
actionpack (= 6.0.0
|
18
|
-
activejob (= 6.0.0
|
19
|
-
activerecord (= 6.0.0
|
20
|
-
activestorage (= 6.0.0
|
21
|
-
activesupport (= 6.0.0
|
16
|
+
actionmailbox (6.0.0)
|
17
|
+
actionpack (= 6.0.0)
|
18
|
+
activejob (= 6.0.0)
|
19
|
+
activerecord (= 6.0.0)
|
20
|
+
activestorage (= 6.0.0)
|
21
|
+
activesupport (= 6.0.0)
|
22
22
|
mail (>= 2.7.1)
|
23
|
-
actionmailer (6.0.0
|
24
|
-
actionpack (= 6.0.0
|
25
|
-
actionview (= 6.0.0
|
26
|
-
activejob (= 6.0.0
|
23
|
+
actionmailer (6.0.0)
|
24
|
+
actionpack (= 6.0.0)
|
25
|
+
actionview (= 6.0.0)
|
26
|
+
activejob (= 6.0.0)
|
27
27
|
mail (~> 2.5, >= 2.5.4)
|
28
28
|
rails-dom-testing (~> 2.0)
|
29
|
-
actionpack (6.0.0
|
30
|
-
actionview (= 6.0.0
|
31
|
-
activesupport (= 6.0.0
|
29
|
+
actionpack (6.0.0)
|
30
|
+
actionview (= 6.0.0)
|
31
|
+
activesupport (= 6.0.0)
|
32
32
|
rack (~> 2.0)
|
33
33
|
rack-test (>= 0.6.3)
|
34
34
|
rails-dom-testing (~> 2.0)
|
35
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
36
|
-
actiontext (6.0.0
|
37
|
-
actionpack (= 6.0.0
|
38
|
-
activerecord (= 6.0.0
|
39
|
-
activestorage (= 6.0.0
|
40
|
-
activesupport (= 6.0.0
|
35
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
+
actiontext (6.0.0)
|
37
|
+
actionpack (= 6.0.0)
|
38
|
+
activerecord (= 6.0.0)
|
39
|
+
activestorage (= 6.0.0)
|
40
|
+
activesupport (= 6.0.0)
|
41
41
|
nokogiri (>= 1.8.5)
|
42
|
-
actionview (6.0.0
|
43
|
-
activesupport (= 6.0.0
|
42
|
+
actionview (6.0.0)
|
43
|
+
activesupport (= 6.0.0)
|
44
44
|
builder (~> 3.1)
|
45
45
|
erubi (~> 1.4)
|
46
46
|
rails-dom-testing (~> 2.0)
|
47
|
-
rails-html-sanitizer (~> 1.
|
48
|
-
activejob (6.0.0
|
49
|
-
activesupport (= 6.0.0
|
47
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
+
activejob (6.0.0)
|
49
|
+
activesupport (= 6.0.0)
|
50
50
|
globalid (>= 0.3.6)
|
51
|
-
activemodel (6.0.0
|
52
|
-
activesupport (= 6.0.0
|
53
|
-
activerecord (6.0.0
|
54
|
-
activemodel (= 6.0.0
|
55
|
-
activesupport (= 6.0.0
|
56
|
-
activestorage (6.0.0
|
57
|
-
actionpack (= 6.0.0
|
58
|
-
|
51
|
+
activemodel (6.0.0)
|
52
|
+
activesupport (= 6.0.0)
|
53
|
+
activerecord (6.0.0)
|
54
|
+
activemodel (= 6.0.0)
|
55
|
+
activesupport (= 6.0.0)
|
56
|
+
activestorage (6.0.0)
|
57
|
+
actionpack (= 6.0.0)
|
58
|
+
activejob (= 6.0.0)
|
59
|
+
activerecord (= 6.0.0)
|
59
60
|
marcel (~> 0.3.1)
|
60
|
-
activesupport (6.0.0
|
61
|
+
activesupport (6.0.0)
|
61
62
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
63
|
i18n (>= 0.7, < 2)
|
63
64
|
minitest (~> 5.1)
|
64
65
|
tzinfo (~> 1.1)
|
65
|
-
zeitwerk (~> 1
|
66
|
-
assignable_values (0.
|
66
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
67
|
+
assignable_values (0.16.1)
|
67
68
|
activerecord (>= 2.3)
|
68
69
|
builder (3.2.3)
|
69
70
|
concurrent-ruby (1.1.5)
|
70
71
|
crass (1.0.4)
|
71
72
|
database_cleaner (1.7.0)
|
72
73
|
diff-lcs (1.3)
|
73
|
-
edge_rider (0.
|
74
|
+
edge_rider (1.0.0)
|
74
75
|
activerecord
|
75
76
|
erubi (1.8.0)
|
76
77
|
gemika (0.3.4)
|
@@ -88,42 +89,42 @@ GEM
|
|
88
89
|
memoized (1.0.2)
|
89
90
|
method_source (0.9.2)
|
90
91
|
mimemagic (0.3.3)
|
91
|
-
mini_mime (1.0.
|
92
|
+
mini_mime (1.0.2)
|
92
93
|
mini_portile2 (2.4.0)
|
93
94
|
minitest (5.11.3)
|
94
|
-
nio4r (2.
|
95
|
-
nokogiri (1.10.
|
95
|
+
nio4r (2.5.1)
|
96
|
+
nokogiri (1.10.4)
|
96
97
|
mini_portile2 (~> 2.4.0)
|
97
98
|
rack (2.0.7)
|
98
99
|
rack-test (1.1.0)
|
99
100
|
rack (>= 1.0, < 3)
|
100
|
-
rails (6.0.0
|
101
|
-
actioncable (= 6.0.0
|
102
|
-
actionmailbox (= 6.0.0
|
103
|
-
actionmailer (= 6.0.0
|
104
|
-
actionpack (= 6.0.0
|
105
|
-
actiontext (= 6.0.0
|
106
|
-
actionview (= 6.0.0
|
107
|
-
activejob (= 6.0.0
|
108
|
-
activemodel (= 6.0.0
|
109
|
-
activerecord (= 6.0.0
|
110
|
-
activestorage (= 6.0.0
|
111
|
-
activesupport (= 6.0.0
|
101
|
+
rails (6.0.0)
|
102
|
+
actioncable (= 6.0.0)
|
103
|
+
actionmailbox (= 6.0.0)
|
104
|
+
actionmailer (= 6.0.0)
|
105
|
+
actionpack (= 6.0.0)
|
106
|
+
actiontext (= 6.0.0)
|
107
|
+
actionview (= 6.0.0)
|
108
|
+
activejob (= 6.0.0)
|
109
|
+
activemodel (= 6.0.0)
|
110
|
+
activerecord (= 6.0.0)
|
111
|
+
activestorage (= 6.0.0)
|
112
|
+
activesupport (= 6.0.0)
|
112
113
|
bundler (>= 1.3.0)
|
113
|
-
railties (= 6.0.0
|
114
|
+
railties (= 6.0.0)
|
114
115
|
sprockets-rails (>= 2.0.0)
|
115
116
|
rails-dom-testing (2.0.3)
|
116
117
|
activesupport (>= 4.2.0)
|
117
118
|
nokogiri (>= 1.6)
|
118
|
-
rails-html-sanitizer (1.0
|
119
|
+
rails-html-sanitizer (1.2.0)
|
119
120
|
loofah (~> 2.2, >= 2.2.2)
|
120
|
-
railties (6.0.0
|
121
|
-
actionpack (= 6.0.0
|
122
|
-
activesupport (= 6.0.0
|
121
|
+
railties (6.0.0)
|
122
|
+
actionpack (= 6.0.0)
|
123
|
+
activesupport (= 6.0.0)
|
123
124
|
method_source
|
124
125
|
rake (>= 0.8.7)
|
125
126
|
thor (>= 0.20.3, < 2.0)
|
126
|
-
rake (12.3.
|
127
|
+
rake (12.3.3)
|
127
128
|
rspec (3.6.0)
|
128
129
|
rspec-core (~> 3.6.0)
|
129
130
|
rspec-expectations (~> 3.6.0)
|
@@ -159,15 +160,15 @@ GEM
|
|
159
160
|
actionpack (>= 4.0)
|
160
161
|
activesupport (>= 4.0)
|
161
162
|
sprockets (>= 3.0.0)
|
162
|
-
sqlite3 (1.
|
163
|
+
sqlite3 (1.4.1)
|
163
164
|
thor (0.20.3)
|
164
165
|
thread_safe (0.3.6)
|
165
166
|
tzinfo (1.2.5)
|
166
167
|
thread_safe (~> 0.1)
|
167
|
-
websocket-driver (0.7.
|
168
|
+
websocket-driver (0.7.1)
|
168
169
|
websocket-extensions (>= 0.1.0)
|
169
|
-
websocket-extensions (0.1.
|
170
|
-
zeitwerk (1.
|
170
|
+
websocket-extensions (0.1.4)
|
171
|
+
zeitwerk (2.1.9)
|
171
172
|
|
172
173
|
PLATFORMS
|
173
174
|
ruby
|
@@ -177,7 +178,7 @@ DEPENDENCIES
|
|
177
178
|
consul!
|
178
179
|
database_cleaner
|
179
180
|
gemika
|
180
|
-
rails (~> 6.0.
|
181
|
+
rails (~> 6.0.0)
|
181
182
|
rspec
|
182
183
|
rspec-rails
|
183
184
|
rspec_candy
|
data/Gemfile.lock
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Gemfile.5-2.lock
|
1
|
+
./Gemfile.5-2.lock
|
data/README.md
CHANGED
@@ -547,7 +547,9 @@ class ApplicationController < ActionController::Base
|
|
547
547
|
end
|
548
548
|
```
|
549
549
|
|
550
|
-
|
550
|
+
Note that this check is satisfied by *any* `.power` directive in the controller class or its ancestors, even if that `.power` directive has `:only` or `:except` options that do not apply to the current action.
|
551
|
+
|
552
|
+
Should you want to forego the power check (e.g. to remove authorization checks from an entirely public controller):
|
551
553
|
|
552
554
|
```rb
|
553
555
|
class ApiController < ApplicationController
|
data/lib/consul/controller.rb
CHANGED
@@ -5,11 +5,7 @@ module Consul
|
|
5
5
|
base.send :include, InstanceMethods
|
6
6
|
base.send :extend, ClassMethods
|
7
7
|
if ensure_power_initializer_present?
|
8
|
-
|
9
|
-
base.before_filter :ensure_power_initializer_present
|
10
|
-
else
|
11
|
-
base.before_action :ensure_power_initializer_present
|
12
|
-
end
|
8
|
+
Util.before_action(base, :ensure_power_initializer_present)
|
13
9
|
end
|
14
10
|
end
|
15
11
|
|
@@ -32,68 +28,35 @@ module Consul
|
|
32
28
|
private
|
33
29
|
|
34
30
|
def require_power_check(options = {})
|
35
|
-
|
36
|
-
before_filter :unchecked_power, options
|
37
|
-
else
|
38
|
-
before_action :unchecked_power, options
|
39
|
-
end
|
31
|
+
Util.before_action(self, :unchecked_power, options)
|
40
32
|
end
|
41
33
|
|
42
34
|
# This is badly named, since it doesn't actually skip the :check_power filter
|
43
35
|
def skip_power_check(options = {})
|
44
|
-
|
45
|
-
skip_before_filter :unchecked_power, options
|
46
|
-
elsif Rails.version.to_i < 5
|
47
|
-
skip_before_action :unchecked_power, options
|
48
|
-
else
|
49
|
-
# Every `power` in a controller will skip the power check filter. After the 1st time, Rails 5+ will raise
|
50
|
-
# an error because there is no `unchecked_power` action to skip any more.
|
51
|
-
# To avoid this, we add the following extra option. Note that it must not be added in Rails 4 to avoid errors.
|
52
|
-
# See http://api.rubyonrails.org/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-skip_callback
|
53
|
-
skip_before_action :unchecked_power, { :raise => false }.merge!(options)
|
54
|
-
end
|
36
|
+
Util.skip_before_action(self, :unchecked_power, options)
|
55
37
|
end
|
56
38
|
|
57
39
|
def current_power(&initializer)
|
58
40
|
self.current_power_initializer = initializer
|
59
|
-
|
60
|
-
around_filter :with_current_power
|
61
|
-
else
|
62
|
-
around_action :with_current_power
|
63
|
-
end
|
41
|
+
Util.around_action(self, :with_current_power)
|
64
42
|
|
65
43
|
if respond_to?(:helper_method)
|
66
44
|
helper_method :current_power
|
67
45
|
end
|
68
46
|
end
|
69
47
|
|
70
|
-
attr_writer :consul_guards
|
71
|
-
|
72
|
-
def consul_guards
|
73
|
-
unless @consul_guards_initialized
|
74
|
-
if superclass && superclass.respond_to?(:consul_guards, true)
|
75
|
-
@consul_guards = superclass.send(:consul_guards).dup
|
76
|
-
else
|
77
|
-
@consul_guards = []
|
78
|
-
end
|
79
|
-
@consul_guards_initialized = true
|
80
|
-
end
|
81
|
-
@consul_guards
|
82
|
-
end
|
83
|
-
|
84
48
|
def power(*args)
|
85
|
-
|
86
49
|
guard = Consul::Guard.new(*args)
|
87
|
-
|
88
|
-
|
50
|
+
|
51
|
+
# One .power directive will skip the check for all actions, even
|
52
|
+
# if that .power directive has :only or :except options.
|
53
|
+
skip_power_check
|
89
54
|
|
90
55
|
# Store arguments for testing
|
91
|
-
|
56
|
+
consul_power_args << args
|
92
57
|
|
93
|
-
|
94
|
-
|
95
|
-
else
|
96
|
-
before_action :check_power, guard.filter_options
|
58
|
+
Util.before_action(self, guard.filter_options) do |controller|
|
59
|
+
guard.ensure!(controller, controller.action_name)
|
97
60
|
end
|
98
61
|
|
99
62
|
if guard.direct_access_method
|
@@ -105,18 +68,26 @@ module Consul
|
|
105
68
|
|
106
69
|
end
|
107
70
|
|
71
|
+
# On first access we inherit .consul_power_args from our ancestor classes.
|
72
|
+
# We also copy inherited args so we don't change our parent's .consul_power_args
|
73
|
+
def consul_power_args
|
74
|
+
unless @consul_power_args_initialized
|
75
|
+
if superclass && superclass.respond_to?(:consul_power_args, true)
|
76
|
+
@consul_power_args = superclass.send(:consul_power_args).dup
|
77
|
+
else
|
78
|
+
@consul_power_args = []
|
79
|
+
end
|
80
|
+
@consul_power_args_initialized = true
|
81
|
+
end
|
82
|
+
@consul_power_args
|
83
|
+
end
|
84
|
+
|
108
85
|
end
|
109
86
|
|
110
87
|
module InstanceMethods
|
111
88
|
|
112
89
|
private
|
113
90
|
|
114
|
-
define_method :check_power do
|
115
|
-
self.class.send(:consul_guards).each do |guard|
|
116
|
-
guard.ensure!(self, action_name)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
91
|
def unchecked_power
|
121
92
|
raise Consul::UncheckedPower, "This controller does not check against a power"
|
122
93
|
end
|
data/lib/consul/spec/matchers.rb
CHANGED
@@ -10,7 +10,7 @@ module Consul
|
|
10
10
|
|
11
11
|
def matches?(controller)
|
12
12
|
@controller_class = controller.class
|
13
|
-
@actual_args = @controller_class.
|
13
|
+
@actual_args = @controller_class.send(:consul_power_args)
|
14
14
|
@actual_args.present? && @actual_args.include?(@expected_args)
|
15
15
|
end
|
16
16
|
|
data/lib/consul/util.rb
CHANGED
@@ -57,6 +57,36 @@ module Consul
|
|
57
57
|
[adjective, record]
|
58
58
|
end
|
59
59
|
|
60
|
+
def skip_before_action(controller_class, name, options)
|
61
|
+
if Rails.version.to_i < 4
|
62
|
+
controller_class.skip_before_filter name, options
|
63
|
+
elsif Rails.version.to_i < 5
|
64
|
+
controller_class.skip_before_action name, options
|
65
|
+
else
|
66
|
+
# Every `power` in a controller will skip the power check filter. After the 1st time, Rails 5+ will raise
|
67
|
+
# an error because there is no `unchecked_power` action to skip any more.
|
68
|
+
# To avoid this, we add the following extra option. Note that it must not be added in Rails 4 to avoid errors.
|
69
|
+
# See http://api.rubyonrails.org/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-skip_callback
|
70
|
+
controller_class.skip_before_action name, { :raise => false }.merge!(options)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def before_action(controller_class, *args, &block)
|
75
|
+
if Rails.version.to_i < 4
|
76
|
+
controller_class.before_filter *args, &block
|
77
|
+
else
|
78
|
+
controller_class.before_action *args, &block
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def around_action(controller_class, *args, &block)
|
83
|
+
if Rails.version.to_i < 4
|
84
|
+
controller_class.around_filter *args, &block
|
85
|
+
else
|
86
|
+
controller_class.around_action *args, &block
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
60
90
|
end
|
61
91
|
end
|
62
92
|
|
data/lib/consul/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: memoized
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.7.8
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: A scope-based authorization solution for Ruby on Rails.
|