drillbit 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/drillbit/authorizable_resource.rb +8 -1
- data/lib/drillbit/authorizers/parameters/filtering.rb +11 -5
- data/lib/drillbit/authorizers/parameters/resource.rb +22 -0
- data/lib/drillbit/authorizers/parameters.rb +1 -1
- data/lib/drillbit/authorizers/query.rb +3 -1
- data/lib/drillbit/authorizers/scope.rb +3 -1
- data/lib/drillbit/middleware/parameter_parser.rb +2 -2
- data/lib/drillbit/requests/rack.rb +2 -0
- data/lib/drillbit/requests/rails.rb +2 -2
- data/lib/drillbit/resource/processors/filtering.rb +1 -1
- data/lib/drillbit/tokens/json_web_tokens/password_reset.rb +1 -1
- data/lib/drillbit/version.rb +1 -1
- data/spec/drillbit/authorizers/parameters/filtering_spec.rb +3 -0
- data/spec/drillbit/authorizers/parameters_spec.rb +1 -0
- data/spec/drillbit/authorizers/query_spec.rb +1 -0
- data/spec/drillbit/authorizers/scope_spec.rb +1 -0
- data/spec/support/private_keys.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +2 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c46b75100d524c1e99a08d7b3c19642e6772743
|
4
|
+
data.tar.gz: 64ca903e7fe42f35463cfd41738a70fd7860f052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7fb6d5553790fb4010b8132333f6d82117d89ce363f65732aecd4626a3e1a7536f8fe8703c3351649c4b4b65cfce4434587fbfe7dff72ac7bfc8ac7d997058
|
7
|
+
data.tar.gz: 2f25c8001b902dfc800d37a4708adecdc10168ef47bad529bc6f0cdbc9d8720b7876b7a37660bff0d5ae9c10c4232f2d7eb3642c66475b6abc7391a4f1af612f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -75,6 +75,7 @@ module AuthorizableResource
|
|
75
75
|
authorizer_class.
|
76
76
|
new(token: token,
|
77
77
|
user: authorized_user,
|
78
|
+
issuer: authorized_issuer,
|
78
79
|
params: authorized_params,
|
79
80
|
resource: authorized_resource)
|
80
81
|
end
|
@@ -85,6 +86,7 @@ module AuthorizableResource
|
|
85
86
|
authorizer_scope_class.
|
86
87
|
new(token: token,
|
87
88
|
user: authorized_user,
|
89
|
+
issuer: authorized_issuer,
|
88
90
|
params: authorized_params,
|
89
91
|
scope_root: authorized_scope_root).
|
90
92
|
call
|
@@ -94,11 +96,12 @@ module AuthorizableResource
|
|
94
96
|
@authorized_params ||= authorizer_params_class.
|
95
97
|
new(token: token,
|
96
98
|
user: authorized_user,
|
99
|
+
issuer: authorized_issuer,
|
97
100
|
params: params).
|
98
101
|
call
|
99
102
|
end
|
100
103
|
|
101
|
-
# rubocop:disable
|
104
|
+
# rubocop:disable Metrics/AbcSize
|
102
105
|
def authorized_attributes
|
103
106
|
@authorized_attributes ||= begin
|
104
107
|
attributes = authorized_params.
|
@@ -163,6 +166,10 @@ module AuthorizableResource
|
|
163
166
|
current_user
|
164
167
|
end
|
165
168
|
|
169
|
+
def authorized_issuer
|
170
|
+
current_issuer
|
171
|
+
end
|
172
|
+
|
166
173
|
def authorization_query
|
167
174
|
@authorization_query ||= "able_to_#{action_name}?"
|
168
175
|
end
|
@@ -46,18 +46,24 @@ class Filtering < Authorizers::Parameters
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
def add_filter_override(name:,
|
50
|
+
value:,
|
51
|
+
only_when_present: false,
|
52
|
+
override_if_admin: false)
|
53
53
|
|
54
54
|
add_filterable_parameter name
|
55
55
|
|
56
56
|
return true if !override_if_admin && token.admin?
|
57
57
|
|
58
|
+
param = params.
|
59
|
+
fetch(:filter, {}).
|
60
|
+
fetch(name, nil)
|
61
|
+
|
62
|
+
return if !param && only_when_present
|
63
|
+
|
58
64
|
params[:filter] ||= {}
|
59
65
|
|
60
|
-
params[:filter][name] = value
|
66
|
+
params[:filter][name] = value
|
61
67
|
end
|
62
68
|
end
|
63
69
|
end
|
@@ -65,6 +65,28 @@ class Resource < Authorizers::Parameters
|
|
65
65
|
add_authorized_relationship(name)
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
def add_attribute_override(name:,
|
70
|
+
value:,
|
71
|
+
only_when_present: false,
|
72
|
+
override_if_admin: false)
|
73
|
+
|
74
|
+
add_authorized_attribute name
|
75
|
+
|
76
|
+
return true if !override_if_admin && token.admin?
|
77
|
+
|
78
|
+
param = params.
|
79
|
+
fetch(:data, {}).
|
80
|
+
fetch(:attributes, {}).
|
81
|
+
fetch(name, nil)
|
82
|
+
|
83
|
+
return if !param && only_when_present
|
84
|
+
|
85
|
+
params[:data] ||= {}
|
86
|
+
params[:data][:attributes] ||= {}
|
87
|
+
|
88
|
+
params[:data][:attributes][name] = value
|
89
|
+
end
|
68
90
|
end
|
69
91
|
end
|
70
92
|
end
|
@@ -7,7 +7,8 @@ class Query
|
|
7
7
|
:params,
|
8
8
|
:resource
|
9
9
|
|
10
|
-
|
10
|
+
# rubocop:disable Metrics/ParameterLists
|
11
|
+
def initialize(token:, user:, issuer:, params:, resource:, **other)
|
11
12
|
self.token = token
|
12
13
|
self.user = user
|
13
14
|
self.params = params
|
@@ -17,6 +18,7 @@ class Query
|
|
17
18
|
public_send("#{name}=", value)
|
18
19
|
end
|
19
20
|
end
|
21
|
+
# rubocop:enable Metrics/ParameterLists
|
20
22
|
|
21
23
|
def able_to_index?
|
22
24
|
false
|
@@ -9,7 +9,8 @@ class Scope
|
|
9
9
|
:params,
|
10
10
|
:scope_root
|
11
11
|
|
12
|
-
|
12
|
+
# rubocop:disable Metrics/ParameterLists
|
13
|
+
def initialize(token:, user:, issuer:, params:, scope_root:, **other)
|
13
14
|
self.token = token
|
14
15
|
self.user = user
|
15
16
|
self.params = params
|
@@ -19,6 +20,7 @@ class Scope
|
|
19
20
|
public_send("#{name}=", value)
|
20
21
|
end
|
21
22
|
end
|
23
|
+
# rubocop:enable Metrics/ParameterLists
|
22
24
|
|
23
25
|
def user_scope
|
24
26
|
scope_root.public_send("for_#{user_underscored_class_name}", scope_user_id)
|
@@ -14,7 +14,7 @@ class ParameterParser
|
|
14
14
|
def call(env)
|
15
15
|
env['QUERY_STRING'] = underscore_query_string(env['QUERY_STRING'])
|
16
16
|
|
17
|
-
if env['CONTENT_LENGTH'].to_i
|
17
|
+
if env['CONTENT_LENGTH'].to_i.positive? && env['CONTENT_TYPE'] =~ /json/
|
18
18
|
if env['rack.input']
|
19
19
|
underscored_input = underscore_request_parameters(env['rack.input'])
|
20
20
|
env['rack.input'] = StringIO.new(underscored_input)
|
@@ -33,7 +33,7 @@ class ParameterParser
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def underscore_request_parameters(request_parameters)
|
36
|
-
data = JSON.
|
36
|
+
data = JSON.parse(request_parameters)
|
37
37
|
data = underscore_parameters(data)
|
38
38
|
|
39
39
|
JSON.dump(data)
|
@@ -5,6 +5,7 @@ require 'drillbit/accept_header'
|
|
5
5
|
require 'drillbit/tokens/json_web_token'
|
6
6
|
require 'drillbit/tokens/base64'
|
7
7
|
|
8
|
+
# rubocop:disable Style/VariableNumber
|
8
9
|
module Drillbit
|
9
10
|
module Requests
|
10
11
|
class Rack < Base
|
@@ -49,3 +50,4 @@ class Rack < Base
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
53
|
+
# rubocop:enable Style/VariableNumber
|
@@ -9,13 +9,13 @@ module Drillbit
|
|
9
9
|
module Requests
|
10
10
|
class Rails < Base
|
11
11
|
def authorization_token_from_params
|
12
|
-
if request.params.
|
12
|
+
if request.params.has_key?(JSON_WEB_TOKEN_PARAM_NAME)
|
13
13
|
Tokens::JsonWebToken.__send__(
|
14
14
|
"from_#{Drillbit.configuration.token_type.downcase}",
|
15
15
|
request.params[JSON_WEB_TOKEN_PARAM_NAME] || '',
|
16
16
|
private_key: token_private_key,
|
17
17
|
)
|
18
|
-
elsif request.params.
|
18
|
+
elsif request.params.has_key?(BASE64_TOKEN_PARAM_NAME)
|
19
19
|
Tokens::Base64.convert(raw_token: request.params[BASE64_TOKEN_PARAM_NAME] || '')
|
20
20
|
else
|
21
21
|
Tokens::Null.instance
|
data/lib/drillbit/version.rb
CHANGED
@@ -11,6 +11,7 @@ describe Filtering do
|
|
11
11
|
it 'can authorize new filter parameters', verify: false do
|
12
12
|
filter_params = Filtering.new(token: '1234',
|
13
13
|
user: '1234',
|
14
|
+
issuer: 'my_issuer',
|
14
15
|
params: params)
|
15
16
|
|
16
17
|
allow(params).to receive(:permit)
|
@@ -31,6 +32,7 @@ describe Filtering do
|
|
31
32
|
}
|
32
33
|
filter_params = Filtering.new(token: '1234',
|
33
34
|
user: '1234',
|
35
|
+
issuer: 'my_issuer',
|
34
36
|
params: params)
|
35
37
|
|
36
38
|
allow(params).to receive(:permit)
|
@@ -45,6 +47,7 @@ describe Filtering do
|
|
45
47
|
it 'has default authorized parameters', verify: false do
|
46
48
|
filter_params = Filtering.new(token: '1234',
|
47
49
|
user: '1234',
|
50
|
+
issuer: 'my_issuer',
|
48
51
|
params: params)
|
49
52
|
|
50
53
|
allow(params).to receive(:permit)
|
@@ -33,6 +33,7 @@ def invalid_jwe_token
|
|
33
33
|
@invalid_jwe_token ||= valid_jwe_token.tr('a', 'f')
|
34
34
|
end
|
35
35
|
|
36
|
+
# rubocop:disable Style/VariableNumber
|
36
37
|
def valid_b64_token(payload = 'hereisacoollittlestring')
|
37
38
|
@valid_b64_token ||= Base64.encode64(payload).chomp
|
38
39
|
end
|
@@ -40,3 +41,4 @@ end
|
|
40
41
|
def invalid_b64_token
|
41
42
|
@invalid_b64_token ||= valid_b64_token.tr('abcdefghijklmnop', '$o#m$k#i$g#e$c#a')
|
42
43
|
end
|
44
|
+
# rubocop:enable Style/VariableNumber
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drillbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thegranddesign
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
zRIv8lqQM8QFT76rzP5SBCERwN+ltKAFbQ5/FwmZNGWYnmCP3RZMQiRnbh+9H9lh
|
32
32
|
mlbwaYZTjgsXq6cy8N38EecewgBbZYS1IYJraE/M
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-
|
34
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: erratum
|
@@ -269,4 +269,3 @@ test_files:
|
|
269
269
|
- spec/fixtures/test_rsa_key.pub
|
270
270
|
- spec/spec_helper.rb
|
271
271
|
- spec/support/private_keys.rb
|
272
|
-
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|