mixlib-authentication 1.4.2 → 2.0.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
- SHA1:
3
- metadata.gz: e493785efc5cf2caf7d1134378fd613f35712f1f
4
- data.tar.gz: d855dabe2ebea778d9c37037e3f843c49acbecb9
2
+ SHA256:
3
+ metadata.gz: 30042f8e3ac0f6ca2d793fa73556e19d41146554c6673788e2c0d7225e9f3584
4
+ data.tar.gz: bed096ad15f32dca36dddfe79deb4f7b9f54a8656849b68393ce900944f3cc5b
5
5
  SHA512:
6
- metadata.gz: '09e094e344bc46528877b69bb015c5d2386ab57da7f7f62edbbeda81dd338fae31194736f56e947d935b0a36306dac06d148b0dbddf5d11cd3249e3cfba65571'
7
- data.tar.gz: 2f71c58ba5d85efbf1d00db61ca09abb57d0092d46e2f8d2fa578baf0c34d2e0ff86e36e1224b40e8d0e1ad8258ef717460dcb06385045d3c920f4cd5052a86b
6
+ metadata.gz: f2bc4eff96e238290c9d3ec9cfc490b62372b9f4b0668dae56055f88844c8b8b971183000e4189d5ecfd8a4cc8b902aee753f103fecb839ad1bf9b33716d1840
7
+ data.tar.gz: 0a03fd4b0a2016b93b681ba5a174dcc49089bd2aab2c2601bad114970a0680fe091bd562a6de4a0918f24e52b3eb512159287a239fb0cf1654ca91c452e34a4f
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ gemspec
3
3
 
4
4
  group(:development) do
5
5
  gem "pry"
6
- gem "mixlib-log"
6
+ gem "mixlib-log", '~> 2'
7
7
  end
@@ -72,7 +72,7 @@ module Mixlib
72
72
  unless @request_signature
73
73
  @request_signature = headers.find_all { |h| h[0].to_s =~ /^x_ops_authorization_/ }
74
74
  .sort { |x, y| x.to_s[/\d+/].to_i <=> y.to_s[/\d+/].to_i }.map { |i| i[1] }.join("\n")
75
- Mixlib::Authentication::Log.debug "Reconstituted (user-supplied) request signature: #{@request_signature}"
75
+ Mixlib::Authentication::Log.trace "Reconstituted (user-supplied) request signature: #{@request_signature}"
76
76
  end
77
77
  @request_signature
78
78
  end
@@ -4,7 +4,7 @@ module Mixlib
4
4
 
5
5
  attr_accessor :level
6
6
 
7
- %i{debug info warn error fatal}.each do |method_name|
7
+ %i{trace debug info warn error fatal}.each do |method_name|
8
8
  class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
9
9
  def #{method_name}(msg=nil, &block)
10
10
  true
@@ -12,7 +12,7 @@ module Mixlib
12
12
  METHOD_DEFN
13
13
  end
14
14
 
15
- %i{debug? info? warn? error? fatal?}.each do |method_name|
15
+ %i{trace? debug? info? warn? error? fatal?}.each do |method_name|
16
16
  class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
17
17
  def #{method_name}
18
18
  false
@@ -76,7 +76,7 @@ module Mixlib
76
76
  # X-Ops-Content-Hash:
77
77
  # X-Ops-Authorization-#{line_number}
78
78
  def authenticate_request(user_secret, time_skew = (15 * 60))
79
- Mixlib::Authentication.logger.debug "Initializing header auth : #{request.inspect}"
79
+ Mixlib::Authentication.logger.trace "Initializing header auth : #{request.inspect}"
80
80
 
81
81
  @user_secret = user_secret
82
82
  @allowed_time_skew = time_skew # in seconds
@@ -149,15 +149,15 @@ module Mixlib
149
149
  (request_decrypted_block == candidate_block)
150
150
  end
151
151
 
152
- # Keep the debug messages lined up so it's easy to scan them
153
- Mixlib::Authentication.logger.debug("Verifying request signature:")
154
- Mixlib::Authentication.logger.debug(" Expected Block is: '#{candidate_block}'")
155
- Mixlib::Authentication.logger.debug("Decrypted block is: '#{request_decrypted_block}'")
156
- Mixlib::Authentication.logger.debug("Signatures match? : '#{@valid_signature}'")
152
+ # Keep the trace messages lined up so it's easy to scan them
153
+ Mixlib::Authentication.logger.trace("Verifying request signature:")
154
+ Mixlib::Authentication.logger.trace(" Expected Block is: '#{candidate_block}'")
155
+ Mixlib::Authentication.logger.trace("Decrypted block is: '#{request_decrypted_block}'")
156
+ Mixlib::Authentication.logger.trace("Signatures match? : '#{@valid_signature}'")
157
157
 
158
158
  @valid_signature
159
159
  rescue => e
160
- Mixlib::Authentication.logger.debug("Failed to verify request signature: #{e.class.name}: #{e.message}")
160
+ Mixlib::Authentication.logger.trace("Failed to verify request signature: #{e.class.name}: #{e.message}")
161
161
  @valid_signature = false
162
162
  end
163
163
 
@@ -168,10 +168,10 @@ module Mixlib
168
168
  def verify_content_hash
169
169
  @valid_content_hash = (content_hash == hashed_body)
170
170
 
171
- # Keep the debug messages lined up so it's easy to scan them
172
- Mixlib::Authentication.logger.debug("Expected content hash is: '#{hashed_body}'")
173
- Mixlib::Authentication.logger.debug(" Request Content Hash is: '#{content_hash}'")
174
- Mixlib::Authentication.logger.debug(" Hashes match?: #{@valid_content_hash}")
171
+ # Keep the trace messages lined up so it's easy to scan them
172
+ Mixlib::Authentication.logger.trace("Expected content hash is: '#{hashed_body}'")
173
+ Mixlib::Authentication.logger.trace(" Request Content Hash is: '#{content_hash}'")
174
+ Mixlib::Authentication.logger.trace(" Hashes match?: #{@valid_content_hash}")
175
175
 
176
176
  @valid_content_hash
177
177
  end
@@ -211,11 +211,11 @@ module Mixlib
211
211
  # Any file that's included in the request is hashed if it's there. Otherwise,
212
212
  # we hash the body.
213
213
  if file_param
214
- Mixlib::Authentication.logger.debug "Digesting file_param: '#{file_param.inspect}'"
214
+ Mixlib::Authentication.logger.trace "Digesting file_param: '#{file_param.inspect}'"
215
215
  @hashed_body = digester.hash_file(file_param, digest)
216
216
  else
217
217
  body = request.raw_post
218
- Mixlib::Authentication.logger.debug "Digesting body: '#{body}'"
218
+ Mixlib::Authentication.logger.trace "Digesting body: '#{body}'"
219
219
  @hashed_body = digester.hash_string(body, digest)
220
220
  end
221
221
  end
@@ -232,7 +232,7 @@ module Mixlib
232
232
  def timestamp_within_bounds?(time1, time2)
233
233
  time_diff = (time2 - time1).abs
234
234
  is_allowed = (time_diff < @allowed_time_skew)
235
- Mixlib::Authentication.logger.debug "Request time difference: #{time_diff}, within #{@allowed_time_skew} seconds? : #{!!is_allowed}"
235
+ Mixlib::Authentication.logger.trace "Request time difference: #{time_diff}, within #{@allowed_time_skew} seconds? : #{!!is_allowed}"
236
236
  is_allowed
237
237
  end
238
238
  end
@@ -115,7 +115,7 @@ module Mixlib
115
115
  header_hash[key] = signature_lines[idx]
116
116
  end
117
117
 
118
- Mixlib::Authentication.logger.debug "Header hash: #{header_hash.inspect}"
118
+ Mixlib::Authentication.logger.trace "Header hash: #{header_hash.inspect}"
119
119
 
120
120
  header_hash
121
121
  end
@@ -236,7 +236,7 @@ module Mixlib
236
236
  memo[field_name.to_sym] = field_value.strip
237
237
  memo
238
238
  end
239
- Mixlib::Authentication.logger.debug "Parsed signing description: #{parts.inspect}"
239
+ Mixlib::Authentication.logger.trace "Parsed signing description: #{parts.inspect}"
240
240
  parts
241
241
  end
242
242
 
@@ -247,7 +247,7 @@ module Mixlib
247
247
  # private
248
248
  def do_sign(private_key, digest, sign_algorithm, sign_version)
249
249
  string_to_sign = canonicalize_request(sign_algorithm, sign_version)
250
- Mixlib::Authentication.logger.debug "String to sign: '#{string_to_sign}'"
250
+ Mixlib::Authentication.logger.trace "String to sign: '#{string_to_sign}'"
251
251
  case sign_version
252
252
  when "1.3"
253
253
  private_key.sign(digest.new, string_to_sign)
@@ -15,6 +15,6 @@
15
15
 
16
16
  module Mixlib
17
17
  module Authentication
18
- VERSION = "1.4.2"
18
+ VERSION = "2.0.0"
19
19
  end
20
20
  end
@@ -63,7 +63,7 @@ class MockFile
63
63
  end
64
64
 
65
65
  # Uncomment this to get some more info from the methods we're testing.
66
- #Mixlib::Authentication.logger.level = :debug
66
+ #Mixlib::Authentication.logger.level = :trace
67
67
 
68
68
  describe "Mixlib::Authentication::SignedHeaderAuth" do
69
69
 
@@ -25,7 +25,7 @@ describe "Mixlib::Authentication::Log" do
25
25
  expect(Mixlib::Authentication::Log.level).to eq(:error)
26
26
  end
27
27
 
28
- %w{debug info warn error fatal}.each do |level|
28
+ %w{trace debug info warn error fatal}.each do |level|
29
29
  it "logs at level #{level}" do
30
30
  expect(Mixlib::Authentication::Log).to receive(level).with("foo")
31
31
 
@@ -44,9 +44,9 @@ describe "Mixlib::Authentication::Log" do
44
44
  .to include(Mixlib::Log)
45
45
  end
46
46
 
47
- %w{debug info warn error fatal}.each do |level|
47
+ %w{trace debug info warn error fatal}.each do |level|
48
48
  it "forward #{level} to mixlib-log" do
49
- expect(Mixlib::Authentication::Log.logger).to receive(level).with("foo")
49
+ expect_any_instance_of(Mixlib::Log).to receive(level).with("foo")
50
50
 
51
51
  Mixlib::Authentication.logger.send(level, "foo")
52
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.6.11
127
+ rubygems_version: 2.7.3
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Mixes in simple per-request authentication