apiphobic-authorization 1.5.0 → 1.6.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: 3ea83f219faa3fde9a7f400699da72998120e0d566d02e3a110da2e503030f90
4
- data.tar.gz: e25f16488e4565a6466d39436f3f2dc497e5fb8ccd2b0fe2dedb520c8a525238
3
+ metadata.gz: ebe1b6813491f637fc907e1d68455b3eb94550c52a77297a12ddfc26d8847975
4
+ data.tar.gz: ecc7acaaee95c033c6b5a9c22c54127abcffe03553890b48a5b89c8c07765008
5
5
  SHA512:
6
- metadata.gz: 9535e821c18f7e8d81972db0cc8ac7d0e04bcb783aa3aa817e3b4ded028687318b60dd34df6d03b8195ff1d7e917cb01a90080a395fab168f3516da13d2ec1e1
7
- data.tar.gz: 30377b4f59ce2cfa8b44ff0913efde6e3a4b0c10b2f40a51a5b388a541defc67d72df2506cdae2c90a29968c8d4691aaadd4386a313276a5d5cfe61c8ba37806
6
+ metadata.gz: 04ca46de212a7b5fb46db8a4f94b809df95ed744e0ea5e0e2a73a8a79359499ddb347d96f8466d54c770eeb67fd356545f037cc36f254dc18ffde4358a956e4c
7
+ data.tar.gz: d853205773ad8b0de8ebfb1ae2704c06ddfe99c296ea7117df5de0f9b431d3c6ed5dd770e837fcb518f55ffb7cb77d7f2b42313b32a74ae60b27c08049588a1b
checksums.yaml.gz.sig CHANGED
Binary file
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2016 The Kompanee, Ltd
1
+ Copyright (c) 2010-2019 The Kompanee, Ltd
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -9,8 +9,7 @@ class Authorizer
9
9
  :token,
10
10
  :audience
11
11
 
12
- # rubocop:disable Metrics/ParameterLists
13
- def initialize(action:, token:, audience:, issuer:, parameters:, resource:, **other)
12
+ def initialize(action:, token:, audience:, issuer:, parameters:, resource:, **other) # rubocop:disable Metrics/ParameterLists
14
13
  self.action = action
15
14
  self.audience = audience
16
15
  self.parameters = parameters
@@ -21,7 +20,6 @@ class Authorizer
21
20
  public_send("#{name}=", value)
22
21
  end
23
22
  end
24
- # rubocop:enable Metrics/ParameterLists
25
23
 
26
24
  alias user audience
27
25
 
@@ -4,7 +4,6 @@ require 'apple_core/refinements/deep_dup'
4
4
  require 'apiphobic/errors/unpermitted_inclusions'
5
5
  require 'apiphobic/errors/unpermitted_sorts'
6
6
 
7
- # rubocop:disable Metrics/ClassLength
8
7
  module Apiphobic
9
8
  module Authorization
10
9
  module Authorizers
@@ -23,8 +22,7 @@ class Parameters
23
22
  :authorized_sorts,
24
23
  :ignored_attributes
25
24
 
26
- # rubocop:disable Metrics/ParameterLists
27
- def initialize(action:, token:, audience:, issuer:, parameters:, **other)
25
+ def initialize(action:, token:, audience:, issuer:, parameters:, **other) # rubocop:disable Metrics/ParameterLists
28
26
  self.action = action
29
27
  self.audience = audience
30
28
  self.parameters = parameters.deep_dup
@@ -34,7 +32,6 @@ class Parameters
34
32
  public_send("#{name}=", value)
35
33
  end
36
34
  end
37
- # rubocop:enable Metrics/ParameterLists
38
35
 
39
36
  alias user audience
40
37
 
@@ -94,8 +91,7 @@ class Parameters
94
91
  @ignored_attributes || []
95
92
  end
96
93
 
97
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
98
- def call
94
+ def call # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
99
95
  sliced_parameters = authorized_parameters.map { |v| v.is_a?(::Hash) ? v[:name] : v }
100
96
 
101
97
  parameters.slice!(*sliced_parameters)
@@ -138,7 +134,6 @@ class Parameters
138
134
 
139
135
  parameters.permit(*authorization)
140
136
  end
141
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
142
137
 
143
138
  private
144
139
 
@@ -197,10 +192,10 @@ class Parameters
197
192
  def authorize_parameter(name:,
198
193
  value:,
199
194
  authorization_parameters:,
200
- authorization_value: nil,
201
195
  raw_parameters:,
202
- allowed_values: nil,
203
- override: {})
196
+ authorization_value: nil,
197
+ allowed_values: nil,
198
+ override: {})
204
199
 
205
200
  value = override_parameter(name: name,
206
201
  value: value,
@@ -211,7 +206,7 @@ class Parameters
211
206
 
212
207
  if authorization_value
213
208
  authorization_parameters[0][name] = authorization_value
214
- elsif value.class == ::Array
209
+ elsif value.instance_of?(::Array)
215
210
  authorization_parameters[0][name] = []
216
211
  else
217
212
  authorization_parameters << name
@@ -254,21 +249,19 @@ class Parameters
254
249
  parameters[:data][:relationships] = raw_parameter_relationships.delete_if(&key_match)
255
250
  end
256
251
 
257
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
258
- def override_parameter(name:, value:, hash:, override:)
252
+ def override_parameter(name:, value:, hash:, override:) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
259
253
  override = { with: nil, if_admin: false, if_absent: true, if_blank: true }
260
254
  .merge(override)
261
255
 
262
- return value unless override[:with] &&
263
- (!token.admin? || override[:if_admin]) &&
264
- (hash.has_key?(name) || override[:if_absent]) &&
265
- (!hash.has_key?(name) || !value.nil? || override[:if_blank])
256
+ return value if !override[:with] ||
257
+ (token.admin? && !override[:if_admin]) ||
258
+ (!hash.has_key?(name) && !override[:if_absent]) ||
259
+ (hash.has_key?(name) && value.nil? && !override[:if_blank])
266
260
 
267
261
  hash[name] = override[:with]
268
262
 
269
263
  override[:with]
270
264
  end
271
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
272
265
 
273
266
  def authorized_data_parameter
274
267
  authorization[0][:data][2]
@@ -286,16 +279,14 @@ class Parameters
286
279
  authorization[0][:filter] ||= [{}]
287
280
  end
288
281
 
289
- # rubocop:disable Layout/ExtraSpacing
290
282
  def raw_parameter_attributes
291
283
  @raw_parameter_attributes ||= begin
292
- parameters[:data] ||= {}
293
- parameters[:data][:attributes] ||= {}
284
+ parameters[:data] ||= {}
285
+ parameters[:data][:attributes] ||= {}
294
286
 
295
- parameters[:data][:attributes]
296
- end
287
+ parameters[:data][:attributes]
288
+ end
297
289
  end
298
- # rubocop:enable Layout/ExtraSpacing
299
290
 
300
291
  def raw_parameter_filters
301
292
  @raw_parameter_filters ||= parameters[:filter] ||= {}
@@ -307,11 +298,11 @@ class Parameters
307
298
 
308
299
  def raw_parameter_relationships
309
300
  @raw_parameter_relationships ||= begin
310
- parameters[:data] ||= {}
311
- parameters[:data][:relationships] ||= {}
301
+ parameters[:data] ||= {}
302
+ parameters[:data][:relationships] ||= {}
312
303
 
313
- parameters[:data][:relationships]
314
- end
304
+ parameters[:data][:relationships]
305
+ end
315
306
  end
316
307
 
317
308
  def raw_parameter_sorts
@@ -337,4 +328,3 @@ end
337
328
  end
338
329
  end
339
330
  end
340
- # rubocop:enable Metrics/ClassLength
@@ -14,8 +14,7 @@ class Scope
14
14
  :scope_root,
15
15
  :token
16
16
 
17
- # rubocop:disable Metrics/ParameterLists
18
- def initialize(action:, token:, audience:, issuer:, parameters:, scope_root:, **other)
17
+ def initialize(action:, token:, audience:, issuer:, parameters:, scope_root:, **other) # rubocop:disable Metrics/ParameterLists
19
18
  self.action = action
20
19
  self.audience = audience
21
20
  self.raw_parameters = parameters
@@ -26,7 +25,6 @@ class Scope
26
25
  public_send("#{name}=", value)
27
26
  end
28
27
  end
29
- # rubocop:enable Metrics/ParameterLists
30
28
 
31
29
  alias user audience
32
30
 
@@ -54,10 +52,12 @@ class Scope
54
52
 
55
53
  def user_underscored_class_name
56
54
  @user_underscored_class_name ||= begin
57
- base_user_class_name = user.class.name[/([^:]+)\z/, 1]
55
+ base_user_class_name = user
56
+ .class
57
+ .name[/([^:]+)\z/, 1]
58
58
 
59
- base_user_class_name.underscore.downcase
60
- end
59
+ base_user_class_name.underscore.downcase
60
+ end
61
61
  end
62
62
 
63
63
  def authorized_scope_id(name:, default:)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apiphobic
4
4
  module Authorization
5
- VERSION = '1.5.0'
5
+ VERSION = '1.6.0'
6
6
  end
7
7
  end
@@ -19,7 +19,7 @@ class UnpermittedInclusions < RuntimeError
19
19
 
20
20
  def detail
21
21
  'One or more of the inclusions you attempted to pass via the "include" parameter ' \
22
- 'are either not available or not authorized.'
22
+ 'are either not available or not authorized.'
23
23
  end
24
24
 
25
25
  def source
data.tar.gz.sig CHANGED
Binary file
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.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -10,28 +10,34 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDqjCCApKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBNMREwDwYDVQQDDAhydWJ5
14
- Z2VtczEjMCEGCgmSJomT8ixkARkWE2xpdmluZ2hpZ2hvbnRoZWJsb2cxEzARBgoJ
15
- kiaJk/IsZAEZFgNjb20wHhcNMTcwODAyMjI1OTM1WhcNMTgwODAyMjI1OTM1WjBN
16
- MREwDwYDVQQDDAhydWJ5Z2VtczEjMCEGCgmSJomT8ixkARkWE2xpdmluZ2hpZ2hv
17
- bnRoZWJsb2cxEzARBgoJkiaJk/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUA
18
- A4IBDwAwggEKAoIBAQDtLa7+7p49gW15OgOyRZad/F92iZcMdDjZ2kAxZlviXgVe
19
- PCtjfdURobH+YMdt++6eRkE25utIFqHyN51Shxfdc21T3fPQe/ZEoMyiJK4tYzbh
20
- 7VjNJG4ldvKKpS1p7iVz9imnyTxNwb0JaIOsOFCA04T0u6aCQi2acNvAPLviXk0q
21
- xJ/CKjI4QUTZKVrBt8Q1Egrp2yzmEnSNftDuTbBb8m4vDR+w325CwbKCgycHJ1/g
22
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MZYV5tX/dJYSGRl9L3s1k2tjoN98q+beNaZQDn21Amml4eK
34
+ KEkMeTTJ2E4GVzR9eKEETLq2LygdUWWZ5NdWOYTxJMdg1GZp3b6X8hJrwfOiizqt
35
+ /ANlIEh11/pOnWa6WPUVpGIMpYdquvmJXnF2LX6zxkKK1hbrebt+vAEAGczgw1Ri
36
+ rkLM6y+BHQdkOTj3VG4MjIU8D4h1Z73Exzxds/VbVKMEz+8JrFjGJ/tYa0PZ8U5p
37
+ 3yXL4G6eW3rdBW/OiLF7GgG2o26d02OMzf4+ubUVS5LQDOcd4vgNPLWzJSBt1YIh
38
+ TgBsED7Me5YdMVXxtTWYsF1VMzaL9hReD3UXGcxe
33
39
  -----END CERTIFICATE-----
34
- date: 2018-07-11 00:00:00.000000000 Z
40
+ date: 2022-07-09 00:00:00.000000000 Z
35
41
  dependencies:
36
42
  - !ruby/object:Gem::Dependency
37
43
  name: apiphobic-resource
@@ -39,14 +45,14 @@ dependencies:
39
45
  requirements:
40
46
  - - "~>"
41
47
  - !ruby/object:Gem::Version
42
- version: '1.0'
48
+ version: '1.2'
43
49
  type: :runtime
44
50
  prerelease: false
45
51
  version_requirements: !ruby/object:Gem::Requirement
46
52
  requirements:
47
53
  - - "~>"
48
54
  - !ruby/object:Gem::Version
49
- version: '1.0'
55
+ version: '1.2'
50
56
  - !ruby/object:Gem::Dependency
51
57
  name: apple_core
52
58
  requirement: !ruby/object:Gem::Requirement
@@ -65,50 +71,44 @@ dependencies:
65
71
  name: erratum
66
72
  requirement: !ruby/object:Gem::Requirement
67
73
  requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 3.1.1
71
74
  - - "~>"
72
75
  - !ruby/object:Gem::Version
73
- version: '3.1'
76
+ version: '4.0'
74
77
  type: :runtime
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
77
80
  requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 3.1.1
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '3.1'
83
+ version: '4.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: actionpack
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '5.0'
90
+ version: '7.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '5.0'
97
+ version: '7.0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rspec
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '3.7'
104
+ version: '3.11'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '3.7'
111
+ version: '3.11'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rspeckled
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -158,11 +158,18 @@ files:
158
158
  - lib/apiphobic/json_api/relationship.rb
159
159
  - lib/apiphobic/rails/api_controller_compatibility.rb
160
160
  - lib/apiphobic/rails/controller.rb
161
- homepage: ''
161
+ homepage: https://github.com/thekompanee/apiphobic-authorization
162
162
  licenses:
163
163
  - MIT
164
164
  metadata:
165
165
  allowed_push_host: https://rubygems.org
166
+ bug_tracker_uri: https://github.com/thekompanee/apiphobic-authorization/issues
167
+ changelog_uri: https://github.com/thekompanee/apiphobic-authorization/blob/master/CHANGELOG.md
168
+ documentation_uri: https://github.com/thekompanee/apiphobic-authorization/tree/releases/v1.6.0
169
+ homepage_uri: https://github.com/thekompanee/apiphobic-authorization
170
+ source_code_uri: https://github.com/thekompanee/apiphobic-authorization
171
+ wiki_uri: https://github.com/thekompanee/apiphobic-authorization/wiki
172
+ rubygems_mfa_required: 'true'
166
173
  post_install_message:
167
174
  rdoc_options: []
168
175
  require_paths:
@@ -178,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
185
  - !ruby/object:Gem::Version
179
186
  version: '0'
180
187
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.7.7
188
+ rubygems_version: 3.3.7
183
189
  signing_key:
184
190
  specification_version: 4
185
191
  summary: Authorization for API Requests
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ��&:w��Fp�k�����3ݵ3��,��d83s�'�[��v��4��0���m��S�<���!�D�ԫ*��=T}gAW+�&���9��se4| Q{F�����:(����}lWho�;�$D�a�P����V��a��P4���̮͟�DE=��楩��5= ���C&2����$��j��Jne��
2
- 43�'A�|���|G���[���Ĕ2e���(݂�p��o��jUC�<�+3ߔ���
1
+ 7�$���3<=<U{_ �� XD';�{x��S4T���t����ٽ|��‘�Af��FqW)+k��F����7p���ˑQ�;T!����\��>ޮ{K�r��J��2\�M�,��)I"�|h e��Sy���j���Oȋ��MmP&$���*LGǹ�8Ќ��"O�@ec��T��GB^&��o���Q;b����j�̜�y��v���������%��l\(U�ƺ��������=i���tX�|�����1,�
2
+ z��U���>�7W�>���z��u:��]����������W ��$N(<�M�>]���PG��I'w�r���(��;��