haveapi 0.21.0 → 0.22.0

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
2
  SHA256:
3
- metadata.gz: 2b5848df30ec9ad0b4ce0539e09cbbb0f8ab46b3ddbd9ebe0c06fbafa08eb842
4
- data.tar.gz: 30218273467496ad5d42c275794de72dfc6a73c74e94022d5230adac64bcd4f6
3
+ metadata.gz: 321e49887ffa5dc763ebc2eb535ee04c5776fc5bcec813feadc0444da1736d9c
4
+ data.tar.gz: e8b1045190e92e6bf38843c3c96be69d66b48490ace40655c3e31721169ce4d4
5
5
  SHA512:
6
- metadata.gz: 8cbf71233376763da8ef40eb176f15d0686b2417a502deb15c1a82efe3079177e31d4664cfebe6269c93abbe7e6f9446027ab1451a0232ddbc3379a0b79e7e5e
7
- data.tar.gz: 4871a061b0c3e85dc8bf1aef0fbedc37d91057281a35fcdae49727cf7ce80d9d318236fd5d231479df927576eb58deea52a82bf9ad8a3516531aae545f4fdd7b
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.21.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'
@@ -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
- ret = call_class_hooks_as_for(
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)
@@ -1,4 +1,4 @@
1
1
  module HaveAPI
2
2
  PROTOCOL_VERSION = '2.0'.freeze
3
- VERSION = '0.21.0'.freeze
3
+ VERSION = '0.22.0'.freeze
4
4
  end
data/shell.nix CHANGED
@@ -6,7 +6,7 @@ in stdenv.mkDerivation rec {
6
6
  name = "haveapi";
7
7
 
8
8
  buildInputs = with pkgs;[
9
- ruby
9
+ ruby_3_2
10
10
  git
11
11
  openssl
12
12
  ];
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.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.21.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.21.0
54
+ version: 0.22.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement