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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06941e32e3b1ca8b7fe4c0796ab5470f2b22148ccfcde6c3c11c17839764148b'
|
4
|
+
data.tar.gz: 9fa62e553609cb05c396ebee78419cce551d72767b097f309546f6d0593e5c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 ||=
|
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::
|
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]) &&
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|