haveapi 0.21.0 → 0.22.0
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 +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
- data/shell.nix +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: 321e49887ffa5dc763ebc2eb535ee04c5776fc5bcec813feadc0444da1736d9c
|
4
|
+
data.tar.gz: e8b1045190e92e6bf38843c3c96be69d66b48490ace40655c3e31721169ce4d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2231a352ccd0e78268b164aa70613fa369462bc9bcaf2bc0fef51d088107c38c78bd43bf26fa01815afadb9ebc9af3c8cd7deae057c80b0b92ad15d75ca8e423
|
7
|
+
data.tar.gz: f736a80afa224ae0c0d687472ad2754660f877a26a3c02b111101d3004c1875c7c3d6927682ee582aef587f98f269a976b33920c738868a516e264b3a66fa4a3
|
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.
|
19
|
+
s.add_runtime_dependency 'haveapi-client', '~> 0.22.0'
|
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
data/shell.nix
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.
|
4
|
+
version: 0.22.0
|
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.
|
47
|
+
version: 0.22.0
|
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.
|
54
|
+
version: 0.22.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|