Class: Presss::Authorization
- Inherits:
-
Object
- Object
- Presss::Authorization
- Defined in:
- lib/presss.rb
Overview
Computes the Authorization header for a AWS request based on a message, the access key ID and secret access key.
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
-
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
Instance Method Summary collapse
-
#header(string) ⇒ Object
Returns the value for the Authorization header for a message contents.
- #hmac_sha1(string) ⇒ Object
-
#initialize(access_key_id, secret_access_key) ⇒ Authorization
constructor
A new instance of Authorization.
-
#sign(string) ⇒ Object
Returns a signature for a AWS request message.
Constructor Details
#initialize(access_key_id, secret_access_key) ⇒ Authorization
Returns a new instance of Authorization.
13 14 15 |
# File 'lib/presss.rb', line 13 def initialize(access_key_id, secret_access_key) @access_key_id, @secret_access_key = access_key_id, secret_access_key end |
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
11 12 13 |
# File 'lib/presss.rb', line 11 def access_key_id @access_key_id end |
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
11 12 13 |
# File 'lib/presss.rb', line 11 def secret_access_key @secret_access_key end |
Instance Method Details
#header(string) ⇒ Object
Returns the value for the Authorization header for a message contents.
18 19 20 |
# File 'lib/presss.rb', line 18 def header(string) 'AWS ' + access_key_id + ':' + sign(string) end |
#hmac_sha1(string) ⇒ Object
27 28 29 |
# File 'lib/presss.rb', line 27 def hmac_sha1(string) OpenSSL::HMAC.digest('sha1', secret_access_key, string) end |
#sign(string) ⇒ Object
Returns a signature for a AWS request message.
23 24 25 |
# File 'lib/presss.rb', line 23 def sign(string) Base64.encode64(hmac_sha1(string)).strip end |