haveapi 0.21.0 → 0.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/haveapi.gemspec +1 -1
- data/lib/haveapi/action.rb +14 -10
- data/lib/haveapi/authorization.rb +5 -0
- data/lib/haveapi/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e72ad9fd9ee5a7d0ada6b5985e28f51d6fe65423b290aae824f6ff55a067145
|
4
|
+
data.tar.gz: c6c35096b29c02199c3dd4ae46d2ee8ec6920e2f5d5436596e4cde1a133c80cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722c8af5849aef6fe6dbbf48d53bb159c66a9dcd4decafcc4ba20a5f6fee441dbe0eb2d08a2f91283dd900869e1e36632281fcabc038a0ad8ed83dbc9255e053
|
7
|
+
data.tar.gz: b26b675cb2ce63c3d7f2723f3084bb7e7289d4ee896dfbdcf875ed841adedc9feb991b3ee76715586fc79d8b21657e537c446e2284aab24dd94361dfbbd78383
|
data/haveapi.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_runtime_dependency 'activesupport', '>= 7.1'
|
18
18
|
s.add_runtime_dependency 'github-markdown'
|
19
|
-
s.add_runtime_dependency 'haveapi-client', '~> 0.21.
|
19
|
+
s.add_runtime_dependency 'haveapi-client', '~> 0.21.1'
|
20
20
|
s.add_runtime_dependency 'json'
|
21
21
|
s.add_runtime_dependency 'mail'
|
22
22
|
s.add_runtime_dependency 'nesty', '~> 1.0'
|
data/lib/haveapi/action.rb
CHANGED
@@ -214,6 +214,7 @@ module HaveAPI
|
|
214
214
|
|
215
215
|
def describe(context)
|
216
216
|
authorization = (@authorization && @authorization.clone) || Authorization.new
|
217
|
+
add_pre_authorize_blocks(authorization, context)
|
217
218
|
|
218
219
|
if (context.endpoint || context.current_user) \
|
219
220
|
&& !authorization.authorized?(context.current_user, context.path_params_from_args)
|
@@ -281,6 +282,18 @@ module HaveAPI
|
|
281
282
|
object.respond_to?(:id) ? object.id : nil
|
282
283
|
end
|
283
284
|
end
|
285
|
+
|
286
|
+
def add_pre_authorize_blocks(authorization, context)
|
287
|
+
ret = Action.call_hooks(
|
288
|
+
:pre_authorize,
|
289
|
+
args: [context],
|
290
|
+
initial: { blocks: [] }
|
291
|
+
)
|
292
|
+
|
293
|
+
ret[:blocks].reverse_each do |block|
|
294
|
+
authorization.prepend_block(block)
|
295
|
+
end
|
296
|
+
end
|
284
297
|
end
|
285
298
|
|
286
299
|
def initialize(request, version, params, body, context)
|
@@ -304,16 +317,7 @@ module HaveAPI
|
|
304
317
|
Authorization.new {}
|
305
318
|
end
|
306
319
|
|
307
|
-
|
308
|
-
Action,
|
309
|
-
:pre_authorize,
|
310
|
-
args: [@context],
|
311
|
-
initial: { blocks: [] }
|
312
|
-
)
|
313
|
-
|
314
|
-
ret[:blocks].reverse_each do |block|
|
315
|
-
@authorization.prepend_block(block)
|
316
|
-
end
|
320
|
+
self.class.add_pre_authorize_blocks(@authorization, @context)
|
317
321
|
end
|
318
322
|
|
319
323
|
def validate!
|
@@ -4,6 +4,11 @@ module HaveAPI
|
|
4
4
|
@blocks = [block]
|
5
5
|
end
|
6
6
|
|
7
|
+
def initialize_clone(other)
|
8
|
+
super
|
9
|
+
@blocks = other.instance_variable_get('@blocks').clone
|
10
|
+
end
|
11
|
+
|
7
12
|
# Returns true if user is authorized.
|
8
13
|
# Block must call allow to authorize user, default rule is deny.
|
9
14
|
def authorized?(user, path_params)
|
data/lib/haveapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haveapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.
|
4
|
+
version: 0.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Skokan
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.21.
|
47
|
+
version: 0.21.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.21.
|
54
|
+
version: 0.21.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|