vagrant-box-s3 0.1.1 → 0.1.3

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: 6c6adbd29229bd4e574f4acb7db8a2ede3d4098bf5759bc4564df93714fc4ba3
4
- data.tar.gz: 89349385e4700a9bf7c66a8ed8d597e460d65a33bfea8ffb57d071dead0c2727
3
+ metadata.gz: 857a4297cb7c77e6fc882a495a81de46e19ec48481e69394450349f4d2ab1462
4
+ data.tar.gz: 54fbc90963cefabf0318fadf73ef4e2370c4438862c75a00041fa727fd4f0780
5
5
  SHA512:
6
- metadata.gz: 6ab64f9ce45890a1ee48a96a13290c334778b4ed16a49dff359afbdba26990a85d328f085d574093fe4b6f8c2ecc449ffc28d39f68f9d5c57d5e1e841c7cafba
7
- data.tar.gz: 625bbb320c28455d9be19a316f63103a96726d4942f7ccab62d5b7cfd9a4b4ab50fcac96df9a5356f2bd4449d9adc15f3543e4b6d607cd8f9b096ec35aa31cde
6
+ metadata.gz: 15d7d800c9636bdcc0fbcab656b46d041f57ee018ac20220689135952289603d9dece21ef7b5c7b8700ca9672ba4e7c4231e09d25b1eade790cc7fdd05e7b39b
7
+ data.tar.gz: 141d2ca407dfda8c5fa8516732dbbafea8c19a15d9c451645a817b14f177a68362797fb22b57726472acbf9a352758440fc376e2f82b08c97031d6e9be8b6296
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Vagrant Box S3
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/vagrant-box-s3.svg)](https://badge.fury.io/rb/vagrant-box-s3)
4
+
3
5
  Use Vagrant boxes stored in Amazon S3 private buckets.
4
6
 
5
7
  ### Requirements
@@ -38,14 +40,14 @@ You can also use your credentials file to create a profile. Select the appropria
38
40
 
39
41
  #### ~/.aws/credentials
40
42
 
41
- [vagrant-s3auth]
43
+ [vagrant-box-s3]
42
44
  aws_access_key_id = AKIA...
43
45
  aws_secret_access_key = ...
44
46
 
45
47
  #### Vagrantfile
46
48
 
47
49
  ENV.delete_if { |name| name.start_with?('AWS_') } # Filter out rogue env vars.
48
- ENV['AWS_PROFILE'] = 'vagrant-s3auth'
50
+ ENV['AWS_PROFILE'] = 'vagrant-box-s3'
49
51
 
50
52
  Vagrant.configure("2") { |config| ... }
51
53
 
@@ -58,10 +60,11 @@ You can use any valid HTTP(S) URL for your box URL:
58
60
  Specify the bucket name in the path of the URL. AWS has deprecated path-style URLs, but they might still be seen or used in legacy systems.
59
61
 
60
62
  - Format: https://s3.Region.amazonaws.com/bucket-name/key-name
61
- Example: https://s3.eu-west-1.amazonaws.com/mybucket/mybox.box
63
+ - Example: https://s3.eu-west-1.amazonaws.com/mybucket/mybox.box
64
+
62
65
 
63
66
  - Format: https://s3-Region.amazonaws.com/bucket-name/keyname
64
- Example: https://s3-eu-west-1.amazonaws.com/bucket-name/mybox.box
67
+ - Example: https://s3-eu-west-1.amazonaws.com/bucket-name/mybox.box
65
68
 
66
69
  #### Virtual-Hosted-Style URLs
67
70
  Virtual-hosted-style URLs use the bucket name as a subdomain. This is the recommended and most commonly used format.
@@ -122,6 +125,10 @@ Update the current version in `lib/vagrant-box-s3/version.rb`.
122
125
 
123
126
  To build the plugin, use `rake build`, this will create a file with the current version number, e.g. `pkg/vagrant-box-s3-0.1.2.gem`.
124
127
 
128
+ Remove the old version:
129
+
130
+ vagrant plugin uninstall vagrant-box-s3
131
+
125
132
  Testing the plugin requires installing into vagrant from the build:
126
133
 
127
134
  vagrant plugin install ../vagrant-box-s3/pkg/vagrant-box-s3-0.1.2.gem
@@ -20,10 +20,14 @@ module Vagrant
20
20
  # Call original execute_curl (aliased).
21
21
  execute_curl_without_aws_auth(options, subprocess_options, &data_proc)
22
22
 
23
+ rescue Aws::Errors::MissingCredentialsError, Aws::Sigv4::Errors::MissingCredentialsError => e
24
+ message = "Missing AWS credentials: #{e.message}"
25
+ @logger.error(message) if defined?(@logger)
26
+ raise Errors::DownloaderError, message: message
23
27
  rescue Aws::S3::Errors::Forbidden => e
24
28
  message = "403 Forbidden: #{e.message}"
25
29
  raise Errors::DownloaderError, message: message
26
- rescue Seahorse::Client::NetworkingError => e
30
+ rescue => e
27
31
  raise Errors::DownloaderError, message: e
28
32
  end
29
33
 
@@ -15,15 +15,15 @@ module VagrantPlugins
15
15
  S3_URL_PATH_REGEX = %r{^https?://s3[-\.]([\w\-]+)\.amazonaws\.com/([^/]+)/([^?]+)}
16
16
 
17
17
  # Parse an s3 URL.
18
- def self.parse_s3_url(s3_url)
18
+ def self.parse_s3_url(url)
19
19
  region = bucket = key = nil
20
- if s3_url =~ S3_URL_HOST_REGEX
21
- match = S3_URL_HOST_REGEX.match(s3_url)
20
+ if url =~ S3_URL_HOST_REGEX
21
+ match = S3_URL_HOST_REGEX.match(url)
22
22
  region = match[2]
23
23
  bucket = match[1]
24
24
  key = match[3]
25
- elsif s3_url =~ S3_URL_PATH_REGEX
26
- match = S3_URL_PATH_REGEX.match(s3_url)
25
+ elsif url =~ S3_URL_PATH_REGEX
26
+ match = S3_URL_PATH_REGEX.match(url)
27
27
  region = match[1]
28
28
  bucket = match[2]
29
29
  key = match[3]
@@ -32,33 +32,64 @@ module VagrantPlugins
32
32
  return region, bucket, key
33
33
  end
34
34
 
35
+ # Remove presigned URL params from box URL.
36
+ # We do this as URLs can be cached and do not want to want
37
+ # to include previously presigned URL parameters.
38
+ def self.remove_presigned_params(url)
39
+ # Parse the URL
40
+ uri = URI.parse(url)
41
+
42
+ # Split the query string into parameters
43
+ query_params = URI.decode_www_form(uri.query || '').to_h
44
+
45
+ # Remove any parameters that start with 'X-Amz-'
46
+ query_params.reject! { |k, _| k.start_with?('X-Amz-') }
47
+
48
+ # Check if there are any query parameters left
49
+ if query_params.empty?
50
+ # If no query parameters left, set uri.query to nil to remove the '?'
51
+ uri.query = nil
52
+ else
53
+ # Reconstruct the query string without AWS presigned parameters
54
+ uri.query = URI.encode_www_form(query_params)
55
+ end
56
+
57
+ return uri.to_s
58
+ end
59
+
35
60
  # Pre-sign an s3 URL, with given method.
36
61
  def self.presign_url(method, url, logger)
37
- logger.info("BoxS3: Generating signed URL for #{method.upcase}")
38
- logger.info("BoxS3: Discovered S3 URL: #{url}")
39
62
 
40
- region, bucket, key = parse_s3_url(url)
63
+ url = remove_presigned_params(url)
64
+
65
+ logger.info("BoxS3: Generating signed URL for #{method.upcase}")
66
+ logger.info("BoxS3: Discovered S3 URL: #{url}")
67
+
68
+ region, bucket, key = parse_s3_url(url)
69
+
70
+ profile = ENV['AWS_PROFILE']
41
71
 
42
- logger.debug("BoxS3: Region: #{region}")
43
- logger.debug("BoxS3: Bucket: #{bucket}")
44
- logger.debug("BoxS3: Key: #{key}")
72
+ logger.debug("BoxS3: Region: #{region}")
73
+ logger.debug("BoxS3: Bucket: #{bucket}")
74
+ logger.debug("BoxS3: Key: #{key}")
75
+ logger.debug("BoxS3: Profile: #{profile}")
45
76
 
46
- client = Aws::S3::Client.new(
47
- profile: ENV['AWS_PROFILE'],
48
- region: region
49
- )
50
- presigner = Aws::S3::Presigner.new(client: client)
77
+ client = Aws::S3::Client.new(
78
+ profile: profile,
79
+ region: region
80
+ )
81
+ presigner = Aws::S3::Presigner.new(client: client)
51
82
 
52
- presigned_url = presigner.presigned_url(
53
- method,
54
- bucket: bucket,
55
- key: key,
56
- expires_in: 3600
57
- ).to_s
83
+ presigned_url = presigner.presigned_url(
84
+ method,
85
+ bucket: bucket,
86
+ key: key,
87
+ expires_in: 3600
88
+ ).to_s
58
89
 
59
- logger.debug("BoxS3: Pre-signed URL: #{presigned_url}")
90
+ logger.debug("BoxS3: Pre-signed URL: #{presigned_url}")
60
91
 
61
- return presigned_url
92
+ return presigned_url
62
93
  end
63
94
 
64
95
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module BoxS3
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-box-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Whiteley
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-13 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '10.0'
55
55
  description: Private, versioned Vagrant boxes hosted on Amazon S3.
56
56
  email:
57
- - steve@memiah.co.uk
57
+ - opensource@memiah.co.uk
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
@@ -68,8 +68,10 @@ files:
68
68
  homepage: https://github.com/memiah/vagrant-box-s3
69
69
  licenses:
70
70
  - MIT
71
- metadata: {}
72
- post_install_message:
71
+ metadata:
72
+ source_code_uri: https://github.com/memiah/vagrant-box-s3
73
+ bug_tracker_uri: https://github.com/memiah/vagrant-box-s3/issues
74
+ post_install_message:
73
75
  rdoc_options: []
74
76
  require_paths:
75
77
  - lib
@@ -82,10 +84,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
84
  requirements:
83
85
  - - ">="
84
86
  - !ruby/object:Gem::Version
85
- version: '0'
87
+ version: 3.0.0
86
88
  requirements: []
87
- rubygems_version: 3.0.3.1
88
- signing_key:
89
+ rubygems_version: 3.4.10
90
+ signing_key:
89
91
  specification_version: 4
90
92
  summary: Amazon AWS S3 Auth.
91
93
  test_files: []