Class: VagrantPlugins::S3Auth::Util::Authenticator
- Inherits:
-
Object
- Object
- VagrantPlugins::S3Auth::Util::Authenticator
- Defined in:
- lib/vagrant-s3auth/util/authenticator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Authenticator
constructor
A new instance of Authenticator.
- #sign(url, method) ⇒ Object
Constructor Details
#initialize ⇒ Authenticator
Returns a new instance of Authenticator.
17 18 19 20 21 22 |
# File 'lib/vagrant-s3auth/util/authenticator.rb', line 17 def initialize @access_key = ENV['AWS_ACCESS_KEY_ID'] @secret_key = ENV['AWS_SECRET_ACCESS_KEY'] ensure_credentials end |
Class Method Details
.sign(url, method) ⇒ Object
13 14 15 |
# File 'lib/vagrant-s3auth/util/authenticator.rb', line 13 def self.sign(url, method) new.sign(url, method) end |
Instance Method Details
#sign(url, method) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-s3auth/util/authenticator.rb', line 24 def sign(url, method) now = CGI.rfc1123_date(Time.now) = "#{method}\n\n\n#{now}\n#{url.path}" signature = Base64.strict_encode64( OpenSSL::HMAC.digest('sha1', @secret_key, )) { date: now, authorization: "AWS #{@access_key}:#{signature}" } end |