bits_service_client 4.0.0.pre.2 → 4.0.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -24
- data/bits_service_client.gemspec +1 -1
- data/lib/bits_service_client/blob.rb +3 -3
- data/lib/bits_service_client/resource_pool.rb +13 -12
- data/lib/bits_service_client/version.rb +1 -1
- data/lib/util/signature_util.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7989da9bc76b9cbec050ebdfd1f1b332968ca6e2
|
4
|
+
data.tar.gz: 623775e563a40638d38b70ea929666c4880d239a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d0c573d721010471df62ad63a6b839cc7148c7fa2d202425cf6c7944fabbad6265a3d7069abd9d36a26311336238e9605601829f4e0aebaa9ab760f0a24489d
|
7
|
+
data.tar.gz: ab24fc0808182958a4ad45622c711ee1fb1a1aca5b1d2808699f3b1be41b6d65a7f2f1e9398a714da642159f11fa4fd57b8b84ae2567bc744e59218bd01eb57a
|
data/README.md
CHANGED
@@ -1,27 +1,3 @@
|
|
1
1
|
# Bits-Service Client
|
2
2
|
|
3
3
|
Ruby client for [bits-service](https://github.com/cloudfoundry-incubator/bits-service).
|
4
|
-
|
5
|
-
# Changelog
|
6
|
-
|
7
|
-
* 0.2.1:
|
8
|
-
- Update list of authors
|
9
|
-
|
10
|
-
* 0.2.0:
|
11
|
-
- Add `vcap_request_id` to `BitsService::Client` and `BitsService::ResourcePool`
|
12
|
-
- Add `request_timeout_in_seconds` to `BitsService::ResourcePool`
|
13
|
-
- Move unit tests from CloudController to this gem
|
14
|
-
|
15
|
-
* 0.1.0: Initial version
|
16
|
-
|
17
|
-
# Bump
|
18
|
-
|
19
|
-
The gem is automatically built and published to [rubygems.org](https://rubygems.org/gems/bits_service_client) in the [flintstone](https://flintstone.ci.cf-app.com) CI pipeline.
|
20
|
-
|
21
|
-
In order to release a new version of the gem, the following steps should be taken:
|
22
|
-
|
23
|
-
1. Update the change log above
|
24
|
-
1. Update [`version.rb`](lib/bits_service_client/version.rb) with the new version
|
25
|
-
1. Check in the changes and push them to `origin`.
|
26
|
-
|
27
|
-
The pipeline will pick up the changes and will, if `version.rb` has changed, tag the release in git and publish the new version of the gem.
|
data/bits_service_client.gemspec
CHANGED
@@ -7,7 +7,7 @@ require 'bits_service_client/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'bits_service_client'
|
9
9
|
spec.version = BitsServiceClient::VERSION
|
10
|
-
spec.authors = ['Rizwan Reza', 'Steffen Uhlig', 'Peter Goetz', 'Norman Sutorius','Tobias Zipfel']
|
10
|
+
spec.authors = ['Rizwan Reza', 'Steffen Uhlig', 'Peter Goetz', 'Norman Sutorius', 'Tobias Zipfel']
|
11
11
|
spec.email = ['rizwanreza@gmail.com', 'steffen.uhlig@de.ibm.com', 'peter.gtz@gmail.com', 'norman.sutorius@de.ibm.com', 'tobias.zipfel@gmail.com']
|
12
12
|
|
13
13
|
spec.summary = 'Bits Services client for Cloud Foundry'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'util/signature_util'
|
3
4
|
|
4
5
|
module BitsService
|
5
6
|
class Blob
|
6
|
-
|
7
7
|
include BitsService::SignatureUtil
|
8
8
|
|
9
9
|
attr_reader :key
|
@@ -28,7 +28,7 @@ module BitsService
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def public_download_url
|
31
|
-
signed_url = "#{@public_endpoint}#{self.sign_signature(resource_path(key), @signing_key_secret, @signing_key_id)}"
|
31
|
+
signed_url = "#{@public_endpoint}#{self.sign_signature('HEAD', resource_path(key), @signing_key_secret, @signing_key_id)}"
|
32
32
|
|
33
33
|
response = @private_http_client.head(signed_url, @vcap_request_id)
|
34
34
|
validate_response_code!([200, 302], response)
|
@@ -41,7 +41,7 @@ module BitsService
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def public_upload_url
|
44
|
-
"#{@public_endpoint}#{self.sign_signature(resource_path(key), @signing_key_secret, @signing_key_id)}&async=true&verb=put"
|
44
|
+
"#{@public_endpoint}#{self.sign_signature('PUT',resource_path(key), @signing_key_secret, @signing_key_id)}&async=true&verb=put"
|
45
45
|
end
|
46
46
|
|
47
47
|
def internal_download_url
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'util/signature_util'
|
3
4
|
|
4
5
|
module BitsService
|
5
6
|
class ResourcePool
|
6
|
-
|
7
7
|
include BitsService::SignatureUtil
|
8
8
|
|
9
9
|
def initialize(bits_service_options:, request_timeout_in_seconds:, vcap_request_id: '')
|
10
|
-
@
|
11
|
-
@public_endpoint = bits_service_options[:public_endpoint]
|
10
|
+
@private_endpoint = URI.parse(bits_service_options[:private_endpoint])
|
11
|
+
@public_endpoint = URI.parse(bits_service_options[:public_endpoint])
|
12
12
|
@request_timeout_in_seconds = request_timeout_in_seconds
|
13
|
-
@signed_key_secret = bits_service_options
|
14
|
-
@signed_key_id = bits_service_options
|
13
|
+
@signed_key_secret = validated(bits_service_options, :signing_key_secret)
|
14
|
+
@signed_key_id = validated(bits_service_options, :signing_key_id)
|
15
15
|
@vcap_request_id = vcap_request_id
|
16
16
|
@logger = Steno.logger('cc.bits_service_client')
|
17
17
|
@ca_cert_path = bits_service_options[:ca_cert_path]
|
@@ -24,10 +24,7 @@ module BitsService
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def signed_matches_url
|
27
|
-
# "
|
28
|
-
signed_url = "#{@public_endpoint}#{self.sign_signature("/app_stash/matches", @signed_key_secret, @signed_key_id)}"
|
29
|
-
@logger.debug("Created signed URL: #{signed_url}")
|
30
|
-
return signed_url
|
27
|
+
"#{@public_endpoint}#{self.sign_signature('POST','/app_stash/matches', @signed_key_secret, @signed_key_id)}"
|
31
28
|
end
|
32
29
|
|
33
30
|
def bundles(resources_json, entries_path)
|
@@ -49,7 +46,7 @@ module BitsService
|
|
49
46
|
|
50
47
|
private
|
51
48
|
|
52
|
-
attr_reader :
|
49
|
+
attr_reader :private_endpoint
|
53
50
|
|
54
51
|
def validate_response_code!(expected, response)
|
55
52
|
return if expected.to_i == response.code.to_i
|
@@ -102,9 +99,9 @@ module BitsService
|
|
102
99
|
end
|
103
100
|
|
104
101
|
def http_client
|
105
|
-
@http_client ||= Net::HTTP.new(
|
102
|
+
@http_client ||= Net::HTTP.new(private_endpoint.host, private_endpoint.port).tap do |c|
|
106
103
|
c.read_timeout = @request_timeout_in_seconds
|
107
|
-
enable_ssl(c, @ca_cert_path) if
|
104
|
+
enable_ssl(c, @ca_cert_path) if private_endpoint.scheme == 'https'
|
108
105
|
end
|
109
106
|
end
|
110
107
|
|
@@ -118,5 +115,9 @@ module BitsService
|
|
118
115
|
http_client.cert_store = cert_store
|
119
116
|
end
|
120
117
|
|
118
|
+
def validated(bits_service_options, attribute)
|
119
|
+
raise ConfigurationError.new("Please provide #{attribute}") unless bits_service_options[attribute]
|
120
|
+
bits_service_options[attribute]
|
121
|
+
end
|
121
122
|
end
|
122
123
|
end
|
data/lib/util/signature_util.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BitsService
|
2
4
|
module SignatureUtil
|
3
|
-
def sign_signature(resource_path, key_secret, key_id)
|
5
|
+
def sign_signature(method, resource_path, key_secret, key_id)
|
4
6
|
expires = seconds_since_the_unix_epoch_with_offset(3600)
|
5
|
-
"#{resource_path}?"
|
6
|
-
"signature=#{OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, key_secret, "#{
|
7
|
-
"expires=#{expires}&"
|
7
|
+
"#{resource_path}?" \
|
8
|
+
"signature=#{OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, key_secret, "#{method.upcase} #{resource_path} #{key_secret} #{expires}")}&" \
|
9
|
+
"expires=#{expires}&" \
|
8
10
|
"AccessKeyId=#{key_id}"
|
9
11
|
end
|
10
12
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bits_service_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.pre.
|
4
|
+
version: 4.0.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rizwan Reza
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2019-01-
|
15
|
+
date: 2019-01-31 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|