mixlib-authentication 1.4.0.rc.0 → 1.4.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mixlib/authentication/digester.rb +3 -2
- data/lib/mixlib/authentication/signatureverification.rb +2 -2
- data/lib/mixlib/authentication/signedheaderauth.rb +4 -4
- data/lib/mixlib/authentication/version.rb +1 -1
- data/spec/mixlib/authentication/digester_spec.rb +24 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07bcb6ac6bcde43d7a76debec94ba82dce31126b
|
4
|
+
data.tar.gz: e524d4f67e7834f75f1e0b02ac5678120aa92533
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76554da7dbe898d3a123786d5edb4e4cddf476f2fedb74bfd1621b0000806f9fef907726cd16dd04c0bb2c59187eddf2a6a25b327af3598006f756665bad817
|
7
|
+
data.tar.gz: 4d18f87f8557dd0fa82fd67f387749d1d228d2c9cda0c747fe3aad5f2cae834940bb57d09df35ce66747fdbcb6b2392a1b02994665bbe128dc04b95030da92aa
|
@@ -17,13 +17,14 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'mixlib/authentication'
|
20
|
+
require 'openssl'
|
20
21
|
|
21
22
|
module Mixlib
|
22
23
|
module Authentication
|
23
24
|
class Digester
|
24
25
|
class << self
|
25
26
|
|
26
|
-
def hash_file(
|
27
|
+
def hash_file(f, digest=OpenSSL::Digest::SHA1)
|
27
28
|
digester = digest.new
|
28
29
|
buf = ""
|
29
30
|
while f.read(16384, buf)
|
@@ -36,7 +37,7 @@ module Mixlib
|
|
36
37
|
#
|
37
38
|
# ====Parameters
|
38
39
|
#
|
39
|
-
def hash_string(
|
40
|
+
def hash_string(str, digest=OpenSSL::Digest::SHA1)
|
40
41
|
::Base64.encode64(digest.digest(str)).chomp
|
41
42
|
end
|
42
43
|
|
@@ -214,11 +214,11 @@ module Mixlib
|
|
214
214
|
# we hash the body.
|
215
215
|
if file_param
|
216
216
|
Mixlib::Authentication::Log.debug "Digesting file_param: '#{file_param.inspect}'"
|
217
|
-
@hashed_body = digester.hash_file(
|
217
|
+
@hashed_body = digester.hash_file(file_param, digest)
|
218
218
|
else
|
219
219
|
body = request.raw_post
|
220
220
|
Mixlib::Authentication::Log.debug "Digesting body: '#{body}'"
|
221
|
-
@hashed_body = digester.hash_string(
|
221
|
+
@hashed_body = digester.hash_string(body, digest)
|
222
222
|
end
|
223
223
|
end
|
224
224
|
@hashed_body
|
@@ -177,9 +177,9 @@ module Mixlib
|
|
177
177
|
# always sign the entire request body, using the expanded multipart
|
178
178
|
# body in the case of a file being include.
|
179
179
|
@hashed_body ||= if self.file && self.file.respond_to?(:read)
|
180
|
-
digester.hash_file(
|
180
|
+
digester.hash_file(self.file, digest)
|
181
181
|
else
|
182
|
-
digester.hash_string(
|
182
|
+
digester.hash_string(self.body, digest)
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -206,7 +206,7 @@ module Mixlib
|
|
206
206
|
else
|
207
207
|
[
|
208
208
|
"Method:#{http_method.to_s.upcase}",
|
209
|
-
"Hashed Path:#{digester.hash_string(
|
209
|
+
"Hashed Path:#{digester.hash_string(canonical_path, digest)}",
|
210
210
|
"X-Ops-Content-Hash:#{hashed_body(digest)}",
|
211
211
|
"X-Ops-Timestamp:#{canonical_time}",
|
212
212
|
"X-Ops-UserId:#{canonical_x_ops_user_id}"
|
@@ -218,7 +218,7 @@ module Mixlib
|
|
218
218
|
case proto_version
|
219
219
|
when "1.1"
|
220
220
|
# and 1.2 if that ever gets implemented
|
221
|
-
digester.hash_string(
|
221
|
+
digester.hash_string(user_id, digest)
|
222
222
|
else
|
223
223
|
# versions 1.0 and 1.3
|
224
224
|
user_id
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mixlib/authentication/digester'
|
2
|
+
|
3
|
+
describe Mixlib::Authentication::Digester do
|
4
|
+
context 'backcompat' do
|
5
|
+
# The digester API should really have been private,
|
6
|
+
# however oc-chef-pedant uses it.
|
7
|
+
let(:test_string) { 'hello' }
|
8
|
+
let(:test_string_checksum) { 'qvTGHdzF6KLavt4PO0gs2a6pQ00=' }
|
9
|
+
|
10
|
+
describe '#hash_file' do
|
11
|
+
it 'should default to use SHA1' do
|
12
|
+
expect(described_class.hash_file(StringIO.new(test_string))).to(
|
13
|
+
eq(test_string_checksum))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#hash_string' do
|
18
|
+
it 'should default to use SHA1' do
|
19
|
+
expect(described_class.hash_string(test_string)).to(
|
20
|
+
eq(test_string_checksum))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
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.0.rc.
|
4
|
+
version: 1.4.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Opscode, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-log
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/mixlib/authentication/signedheaderauth.rb
|
102
102
|
- lib/mixlib/authentication/version.rb
|
103
103
|
- mixlib-authentication.gemspec
|
104
|
+
- spec/mixlib/authentication/digester_spec.rb
|
104
105
|
- spec/mixlib/authentication/http_authentication_request_spec.rb
|
105
106
|
- spec/mixlib/authentication/mixlib_authentication_spec.rb
|
106
107
|
- spec/spec_helper.rb
|