apiphobic-authorization 1.0.0 → 1.1.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: b495a30be17fcd8a76aac415fcbf6d98e56f074c782fb8b97da5485ef5c87117
4
- data.tar.gz: 4540fba22161f2ca8169e8daad77c4c868911e33a1792d58fb1bf66df66d1e35
3
+ metadata.gz: '06941e32e3b1ca8b7fe4c0796ab5470f2b22148ccfcde6c3c11c17839764148b'
4
+ data.tar.gz: 9fa62e553609cb05c396ebee78419cce551d72767b097f309546f6d0593e5c92
5
5
  SHA512:
6
- metadata.gz: 3fdbe8d14d7a0cc433d73c71a2292470ff50a13182681a0f56d18959944393a8884027367ef19518027c843daa66cf9344ec22e5648d64d8f2526a9b71d1090d
7
- data.tar.gz: 2c9a91ca38d27f3b78ee561481c12c4aeed6f920e77e19ac96b8e348f37575f93e362a4cbb1285e4adb0dc7a50bc634fc6a1b74b31d17b6120b06ff41afab952
6
+ metadata.gz: 5aca4483586dc0c98994ce92f91cda8d50666d1396f8ed867a621a17d818a179bb6c14ef42fa411dbad083c868ba5b33166998f0ccc2920949df8efd788d85df
7
+ data.tar.gz: acc4a4d9dc689600e459a2817e24a7246ca976d70edb169291cc4b22570be807feffd8e5ecdeee0d91091196e4d24f0a9d0275092624e79b58fc7d2f22e5655d
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -105,14 +105,17 @@ module Resource
105
105
  def authorized_resource
106
106
  return if RESOURCE_COLLECTION_ACTIONS.include?(action_name)
107
107
 
108
- @authorized_resource ||= public_send(self.class.singular_resource_name)
108
+ @authorized_resource ||= \
109
+ Resource::Model
110
+ .new(resource: public_send(self.class.plural_resource_name),
111
+ parameters: authorized_parameters)
109
112
  end
110
113
 
111
114
  def authorized_collection
112
115
  return unless RESOURCE_COLLECTION_ACTIONS.include?(action_name)
113
116
 
114
117
  @authorized_collection ||= \
115
- Resource::Model
118
+ Resource::Collection
116
119
  .new(resource: public_send(self.class.plural_resource_name),
117
120
  parameters: authorized_parameters)
118
121
  end
@@ -19,7 +19,8 @@ class Parameters
19
19
  :authorized_filters,
20
20
  :authorized_inclusions,
21
21
  :authorized_relationships,
22
- :authorized_sorts
22
+ :authorized_sorts,
23
+ :ignored_attributes
23
24
 
24
25
  # rubocop:disable Metrics/ParameterLists
25
26
  def initialize(action:, token:, user:, issuer:, parameters:, **other)
@@ -54,6 +55,10 @@ class Parameters
54
55
  @authorized_sorts || []
55
56
  end
56
57
 
58
+ def ignored_attributes
59
+ @ignored_attributes || []
60
+ end
61
+
57
62
  def call
58
63
  authorized_attributes.each do |attribute|
59
64
  attribute = { name: attribute } unless attribute.is_a?(::Hash)
@@ -61,6 +66,12 @@ class Parameters
61
66
  authorize_attribute(**attribute)
62
67
  end
63
68
 
69
+ ignored_attributes.each do |attribute|
70
+ attribute = { name: attribute } unless attribute.is_a?(::Hash)
71
+
72
+ ignore_attribute(**attribute)
73
+ end
74
+
64
75
  authorized_filters.each do |filter|
65
76
  filter = { name: filter } unless filter.is_a?(::Hash)
66
77
 
@@ -197,6 +208,10 @@ class Parameters
197
208
  end
198
209
  end
199
210
 
211
+ def ignore_attribute(name:)
212
+ raw_parameter_attributes.delete(name)
213
+ end
214
+
200
215
  def override_parameter(name:, value:, hash:, override:)
201
216
  return value unless override[:with] &&
202
217
  (!token.admin? || override[:if_admin]) &&
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apiphobic
4
4
  module Authorization
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiphobic-authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
metadata.gz.sig CHANGED
Binary file