vagrant-s3auth 0.0.2 → 0.1.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +70 -15
- data/Rakefile +5 -0
- data/lib/vagrant-s3auth/{action → extensions}/box_add.rb +0 -0
- data/lib/vagrant-s3auth/extensions/downloader.rb +38 -0
- data/lib/vagrant-s3auth/extensions.rb +2 -0
- data/lib/vagrant-s3auth/plugin.rb +1 -25
- data/lib/vagrant-s3auth/util/authenticator.rb +53 -0
- data/lib/vagrant-s3auth/version.rb +1 -1
- data/lib/vagrant-s3auth.rb +1 -0
- metadata +8 -7
- data/lib/vagrant-s3auth/action/authenticate_box_url.rb +0 -86
- data/lib/vagrant-s3auth/action.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24bd022cbfa2876c12e53ab63524d0223c1db2bc
|
4
|
+
data.tar.gz: a4c3000842d64b4cd7e86a1916f3059b82a29d59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9106c22b6c8982f6e2fe6f54d3c11835f6361d478b22b0128e862bb2f67d73a17d34570253283730f16cda6c04a05e0403e0a05a7b4dda013fa7d6a5d10939fd
|
7
|
+
data.tar.gz: 7a1be0554b1811f140a2ec74184869984ab4256d3389d2ba7e960c702821fd2a6626aed874a06ab2f30bdc7fb4f4008081ad43d802271f92331d3e2c33188c24
|
data/.rubocop.yml
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
1
|
+
Lint/AssignmentInCondition:
|
2
2
|
Enabled: false
|
3
3
|
|
4
|
-
|
4
|
+
Style/AlignParameters:
|
5
|
+
EnforcedStyle: with_fixed_indentation
|
6
|
+
|
7
|
+
Style/Documentation:
|
5
8
|
Enabled: false
|
6
9
|
|
7
|
-
|
10
|
+
Style/FileName:
|
8
11
|
Enabled: false
|
9
12
|
|
10
|
-
LineLength:
|
13
|
+
Style/LineLength:
|
11
14
|
Max: 100
|
12
15
|
|
13
|
-
MethodLength:
|
16
|
+
Style/MethodLength:
|
14
17
|
CountComments: false # count full line comments?
|
15
18
|
Max: 20
|
16
19
|
|
17
|
-
SignalException:
|
20
|
+
Style/SignalException:
|
18
21
|
EnforcedStyle: only_raise
|
19
|
-
SupportedStyles:
|
20
|
-
- only_raise
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,58 +1,113 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/mitchellh/vagrant.git
|
3
|
-
revision:
|
3
|
+
revision: f0cd8511ed3784415df14aa17b7e4b4935733b63
|
4
4
|
specs:
|
5
|
-
vagrant (1.
|
6
|
-
bundler (
|
5
|
+
vagrant (1.6.4.dev)
|
6
|
+
bundler (>= 1.5.2, < 1.7.0)
|
7
7
|
childprocess (~> 0.5.0)
|
8
8
|
erubis (~> 2.7.0)
|
9
9
|
i18n (~> 0.6.0)
|
10
10
|
listen (~> 2.7.1)
|
11
11
|
log4r (~> 1.1.9, < 1.1.11)
|
12
12
|
net-scp (~> 1.1.0)
|
13
|
-
net-ssh (>= 2.6.6, < 2.
|
13
|
+
net-ssh (>= 2.6.6, < 2.10.0)
|
14
14
|
rb-kqueue (~> 0.2.0)
|
15
15
|
wdm (~> 0.1.0)
|
16
|
+
winrm (~> 1.1.3)
|
16
17
|
|
17
18
|
PATH
|
18
19
|
remote: .
|
19
20
|
specs:
|
20
|
-
vagrant-s3auth (0.0.
|
21
|
+
vagrant-s3auth (0.1.0.alpha1)
|
21
22
|
|
22
23
|
GEM
|
23
24
|
remote: https://rubygems.org/
|
24
25
|
specs:
|
26
|
+
akami (1.2.2)
|
27
|
+
gyoku (>= 0.4.0)
|
28
|
+
nokogiri
|
29
|
+
ast (2.0.0)
|
30
|
+
builder (3.2.2)
|
25
31
|
celluloid (0.15.2)
|
26
32
|
timers (~> 1.1.0)
|
27
|
-
|
28
|
-
celluloid (>= 0.15.0)
|
29
|
-
nio4r (>= 0.5.0)
|
30
|
-
childprocess (0.5.2)
|
33
|
+
childprocess (0.5.3)
|
31
34
|
ffi (~> 1.0, >= 1.0.11)
|
32
35
|
erubis (2.7.0)
|
33
36
|
ffi (1.9.3)
|
37
|
+
gssapi (1.0.3)
|
38
|
+
ffi (>= 1.0.1)
|
39
|
+
gyoku (1.1.1)
|
40
|
+
builder (>= 2.1.2)
|
41
|
+
httpclient (2.4.0)
|
42
|
+
httpi (0.9.7)
|
43
|
+
rack
|
34
44
|
i18n (0.6.9)
|
35
|
-
|
45
|
+
json (1.8.1)
|
46
|
+
listen (2.7.8)
|
36
47
|
celluloid (>= 0.15.2)
|
37
|
-
celluloid-io (>= 0.15.0)
|
38
48
|
rb-fsevent (>= 0.9.3)
|
39
49
|
rb-inotify (>= 0.9)
|
50
|
+
little-plugger (1.1.3)
|
40
51
|
log4r (1.1.10)
|
52
|
+
logging (1.8.2)
|
53
|
+
little-plugger (>= 1.1.3)
|
54
|
+
multi_json (>= 1.8.4)
|
55
|
+
mini_portile (0.6.0)
|
56
|
+
multi_json (1.10.1)
|
41
57
|
net-scp (1.1.2)
|
42
58
|
net-ssh (>= 2.6.5)
|
43
|
-
net-ssh (2.
|
44
|
-
|
59
|
+
net-ssh (2.9.1)
|
60
|
+
nokogiri (1.6.2.1)
|
61
|
+
mini_portile (= 0.6.0)
|
62
|
+
nori (1.1.5)
|
63
|
+
parser (2.1.9)
|
64
|
+
ast (>= 1.1, < 3.0)
|
65
|
+
slop (~> 3.4, >= 3.4.5)
|
66
|
+
powerpack (0.0.9)
|
67
|
+
rack (1.5.2)
|
68
|
+
rainbow (2.0.0)
|
69
|
+
rake (10.3.2)
|
45
70
|
rb-fsevent (0.9.4)
|
46
|
-
rb-inotify (0.9.
|
71
|
+
rb-inotify (0.9.5)
|
47
72
|
ffi (>= 0.5.0)
|
48
|
-
rb-kqueue (0.2.
|
73
|
+
rb-kqueue (0.2.3)
|
49
74
|
ffi (>= 0.5.0)
|
75
|
+
rubocop (0.23.0)
|
76
|
+
json (>= 1.7.7, < 2)
|
77
|
+
parser (~> 2.1.9)
|
78
|
+
powerpack (~> 0.0.6)
|
79
|
+
rainbow (>= 1.99.1, < 3.0)
|
80
|
+
ruby-progressbar (~> 1.4)
|
81
|
+
ruby-progressbar (1.5.1)
|
82
|
+
rubyntlm (0.1.1)
|
83
|
+
savon (0.9.5)
|
84
|
+
akami (~> 1.0)
|
85
|
+
builder (>= 2.1.2)
|
86
|
+
gyoku (>= 0.4.0)
|
87
|
+
httpi (~> 0.9)
|
88
|
+
nokogiri (>= 1.4.0)
|
89
|
+
nori (~> 1.0)
|
90
|
+
wasabi (~> 1.0)
|
91
|
+
slop (3.5.0)
|
50
92
|
timers (1.1.0)
|
93
|
+
uuidtools (2.1.4)
|
94
|
+
wasabi (1.0.0)
|
95
|
+
nokogiri (>= 1.4.0)
|
51
96
|
wdm (0.1.0)
|
97
|
+
winrm (1.1.3)
|
98
|
+
gssapi (~> 1.0.0)
|
99
|
+
httpclient (~> 2.2, >= 2.2.0.2)
|
100
|
+
logging (~> 1.6, >= 1.6.1)
|
101
|
+
nokogiri (~> 1.5)
|
102
|
+
rubyntlm (~> 0.1.1)
|
103
|
+
savon (= 0.9.5)
|
104
|
+
uuidtools (~> 2.1.2)
|
52
105
|
|
53
106
|
PLATFORMS
|
54
107
|
ruby
|
55
108
|
|
56
109
|
DEPENDENCIES
|
110
|
+
rake (~> 10.3.2)
|
111
|
+
rubocop (~> 0.23.0)
|
57
112
|
vagrant!
|
58
113
|
vagrant-s3auth!
|
data/Rakefile
CHANGED
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
require 'vagrant/util/downloader'
|
4
|
+
require 'vagrant-s3auth/util/authenticator'
|
5
|
+
|
6
|
+
module Vagrant
|
7
|
+
module Util
|
8
|
+
class Downloader
|
9
|
+
def execute_curl_with_s3(options, subprocess_options, &data_proc)
|
10
|
+
begin
|
11
|
+
url = URI.parse(@source)
|
12
|
+
rescue URI::InvalidURIError
|
13
|
+
@logger.info("s3auth: Ignoring unparsable URL: #{url}")
|
14
|
+
end
|
15
|
+
|
16
|
+
if url && s3_url?(url)
|
17
|
+
@logger.info("s3auth: Signing S3 URL: #{url}")
|
18
|
+
|
19
|
+
method = options.any? { |o| o == '-I' } ? 'HEAD' : 'GET'
|
20
|
+
headers = VagrantPlugins::S3Auth::Util::Authenticator.sign(url, method)
|
21
|
+
|
22
|
+
headers.each do |name, value|
|
23
|
+
options << '-H' << "#{name}: #{value}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
execute_curl_without_s3(options, subprocess_options, &data_proc)
|
28
|
+
end
|
29
|
+
|
30
|
+
def s3_url?(url)
|
31
|
+
url.host =~ VagrantPlugins::S3Auth::S3_HOST_MATCHER
|
32
|
+
end
|
33
|
+
|
34
|
+
alias_method :execute_curl_without_s3, :execute_curl
|
35
|
+
alias_method :execute_curl, :execute_curl_with_s3
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -8,8 +8,8 @@ if Vagrant::VERSION < '1.5.0'
|
|
8
8
|
raise 'The Vagrant AWS plugin is only compatible with Vagrant 1.5+'
|
9
9
|
end
|
10
10
|
|
11
|
-
require_relative 'action'
|
12
11
|
require_relative 'errors'
|
12
|
+
require_relative 'extensions'
|
13
13
|
|
14
14
|
module VagrantPlugins
|
15
15
|
module S3Auth
|
@@ -20,34 +20,10 @@ module VagrantPlugins
|
|
20
20
|
Use versioned Vagrant boxes with S3 authentication.
|
21
21
|
DESC
|
22
22
|
|
23
|
-
action_hook 'authenticate-box-url', :authenticate_box_url do |hook|
|
24
|
-
setup_i18n
|
25
|
-
setup_logging
|
26
|
-
|
27
|
-
hook.append(Action.authenticate_box_url)
|
28
|
-
end
|
29
|
-
|
30
23
|
def self.setup_i18n
|
31
24
|
I18n.load_path << File.expand_path('locales/en.yml', VagrantPlugins::S3Auth.source_root)
|
32
25
|
I18n.reload!
|
33
26
|
end
|
34
|
-
|
35
|
-
def self.setup_logging
|
36
|
-
require 'log4r'
|
37
|
-
|
38
|
-
level = nil
|
39
|
-
begin
|
40
|
-
level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
|
41
|
-
rescue NameError
|
42
|
-
level = nil
|
43
|
-
end
|
44
|
-
|
45
|
-
if level
|
46
|
-
logger = Log4r::Logger.new('vagrant_s3auth')
|
47
|
-
logger.outputters = Log4r::Outputter.stderr
|
48
|
-
logger.level = level
|
49
|
-
end
|
50
|
-
end
|
51
27
|
end
|
52
28
|
end
|
53
29
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'cgi'
|
3
|
+
require 'log4r'
|
4
|
+
require 'openssl'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'vagrant/util/downloader'
|
8
|
+
|
9
|
+
module VagrantPlugins
|
10
|
+
module S3Auth
|
11
|
+
module Util
|
12
|
+
class Authenticator
|
13
|
+
def self.sign(url, method)
|
14
|
+
new.sign(url, method)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@access_key = ENV['AWS_ACCESS_KEY_ID']
|
19
|
+
@secret_key = ENV['AWS_SECRET_ACCESS_KEY']
|
20
|
+
|
21
|
+
ensure_credentials
|
22
|
+
end
|
23
|
+
|
24
|
+
def sign(url, method)
|
25
|
+
now = CGI.rfc1123_date(Time.now)
|
26
|
+
message = "#{method}\n\n\n#{now}\n#{url.path}"
|
27
|
+
signature = Base64.strict_encode64(
|
28
|
+
OpenSSL::HMAC.digest('sha1', @secret_key, message))
|
29
|
+
|
30
|
+
{
|
31
|
+
date: now,
|
32
|
+
authorization: "AWS #{@access_key}:#{signature}"
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def ensure_credentials
|
39
|
+
missing_variables = []
|
40
|
+
missing_variables << 'AWS_ACCESS_KEY_ID' unless @access_key
|
41
|
+
missing_variables << 'AWS_SECRET_ACCESS_KEY' unless @secret_key
|
42
|
+
|
43
|
+
# rubocop:disable Style/GuardClause
|
44
|
+
unless missing_variables.empty?
|
45
|
+
raise Errors::MissingCredentialsError,
|
46
|
+
missing_variables: missing_variables.join(', ')
|
47
|
+
end
|
48
|
+
# rubocop:enable Style/GuardClause
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/vagrant-s3auth.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-s3auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.1.0.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikhil Benesch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,11 +54,12 @@ files:
|
|
54
54
|
- README.md
|
55
55
|
- Rakefile
|
56
56
|
- lib/vagrant-s3auth.rb
|
57
|
-
- lib/vagrant-s3auth/action.rb
|
58
|
-
- lib/vagrant-s3auth/action/authenticate_box_url.rb
|
59
|
-
- lib/vagrant-s3auth/action/box_add.rb
|
60
57
|
- lib/vagrant-s3auth/errors.rb
|
58
|
+
- lib/vagrant-s3auth/extensions.rb
|
59
|
+
- lib/vagrant-s3auth/extensions/box_add.rb
|
60
|
+
- lib/vagrant-s3auth/extensions/downloader.rb
|
61
61
|
- lib/vagrant-s3auth/plugin.rb
|
62
|
+
- lib/vagrant-s3auth/util/authenticator.rb
|
62
63
|
- lib/vagrant-s3auth/version.rb
|
63
64
|
- locales/en.yml
|
64
65
|
- vagrant-s3auth.gemspec
|
@@ -77,9 +78,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
78
|
version: '0'
|
78
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
|
-
- - '
|
81
|
+
- - '>'
|
81
82
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
+
version: 1.3.1
|
83
84
|
requirements: []
|
84
85
|
rubyforge_project:
|
85
86
|
rubygems_version: 2.0.14
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
require 'cgi'
|
3
|
-
require 'log4r'
|
4
|
-
require 'openssl'
|
5
|
-
require 'uri'
|
6
|
-
|
7
|
-
module VagrantPlugins
|
8
|
-
module S3Auth
|
9
|
-
module Action
|
10
|
-
class AuthenticateBoxUrl
|
11
|
-
def initialize(app, env)
|
12
|
-
@app = app
|
13
|
-
@logger = Log4r::Logger.new('vagrant_s3auth::action::authenticate_box_url')
|
14
|
-
@access_key = ENV['AWS_ACCESS_KEY_ID']
|
15
|
-
@secret_key = ENV['AWS_SECRET_ACCESS_KEY']
|
16
|
-
end
|
17
|
-
|
18
|
-
def call(env)
|
19
|
-
env[:box_urls].map! do |url_string|
|
20
|
-
begin
|
21
|
-
url = URI.parse(url_string)
|
22
|
-
rescue URI::InvalidURIError
|
23
|
-
next url_string
|
24
|
-
end
|
25
|
-
|
26
|
-
unless s3_url?(url)
|
27
|
-
@logger.debug("Skipping non-S3 host: #{url}")
|
28
|
-
next url_string
|
29
|
-
end
|
30
|
-
|
31
|
-
# Vagrant makes a HEAD request for metadata. S3 doesn't support
|
32
|
-
# query-string authentication on HEAD requests, so skip signing. We
|
33
|
-
# need to provide a different "authenticated" URL, though, or
|
34
|
-
# Vagrant will think the box doesn't require authentication,
|
35
|
-
# and won't request an authenticated URL for the box itself.
|
36
|
-
unless box_url?(url)
|
37
|
-
@logger.debug("Munging S3 metadata URL: #{url}")
|
38
|
-
next url_string + '?'
|
39
|
-
end
|
40
|
-
|
41
|
-
@logger.info("Signing URL for S3 box: #{url}")
|
42
|
-
sign(url)
|
43
|
-
end
|
44
|
-
|
45
|
-
@app.call(env)
|
46
|
-
end
|
47
|
-
|
48
|
-
def sign(url)
|
49
|
-
ensure_credentials
|
50
|
-
|
51
|
-
expires = (Time.now + 20).to_i
|
52
|
-
message = "GET\n\n\n#{expires}\n#{url.path}"
|
53
|
-
signature = CGI.escape(Base64.strict_encode64(
|
54
|
-
OpenSSL::HMAC.digest('sha1', @secret_key, message)))
|
55
|
-
|
56
|
-
url.query = {
|
57
|
-
'AWSAccessKeyId' => @access_key,
|
58
|
-
'Expires' => expires,
|
59
|
-
'Signature' => signature
|
60
|
-
}.map { |k, v| "#{k}=#{v}" }.join('&')
|
61
|
-
|
62
|
-
url.to_s
|
63
|
-
end
|
64
|
-
|
65
|
-
def ensure_credentials
|
66
|
-
missing_variables = []
|
67
|
-
missing_variables << 'AWS_ACCESS_KEY_ID' unless @access_key
|
68
|
-
missing_variables << 'AWS_SECRET_ACCESS_KEY' unless @secret_key
|
69
|
-
|
70
|
-
unless missing_variables.empty?
|
71
|
-
raise Errors::MissingCredentialsError,
|
72
|
-
missing_variables: missing_variables.join(', ')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def s3_url?(url)
|
77
|
-
url.host == S3_HOST
|
78
|
-
end
|
79
|
-
|
80
|
-
def box_url?(url)
|
81
|
-
url.path.end_with?('.box')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative 'action/authenticate_box_url'
|
2
|
-
require_relative 'action/box_add'
|
3
|
-
|
4
|
-
module VagrantPlugins
|
5
|
-
module S3Auth
|
6
|
-
module Action
|
7
|
-
def self.authenticate_box_url
|
8
|
-
Vagrant::Action::Builder.new.tap do |b|
|
9
|
-
b.use AuthenticateBoxUrl
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|