Class: AWS4::Signer
- Inherits:
-
Object
- Object
- AWS4::Signer
- Defined in:
- lib/aws4/signer.rb
Constant Summary collapse
- RFC8601BASIC =
"%Y%m%dT%H%M%SZ"
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(config) ⇒ Signer
constructor
A new instance of Signer.
- #sign(method, uri, headers, body, debug = false) ⇒ Object
Constructor Details
#initialize(config) ⇒ Signer
Returns a new instance of Signer.
13 14 15 16 17 |
# File 'lib/aws4/signer.rb', line 13 def initialize(config) @access_key = config[:access_key] || config["access_key"] @secret_key = config[:secret_key] || config["secret_key"] @region = config[:region] || config["region"] end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
10 11 12 |
# File 'lib/aws4/signer.rb', line 10 def access_key @access_key end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/aws4/signer.rb', line 11 def body @body end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
11 12 13 |
# File 'lib/aws4/signer.rb', line 11 def date @date end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
11 12 13 |
# File 'lib/aws4/signer.rb', line 11 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
11 12 13 |
# File 'lib/aws4/signer.rb', line 11 def method @method end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
10 11 12 |
# File 'lib/aws4/signer.rb', line 10 def region @region end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
10 11 12 |
# File 'lib/aws4/signer.rb', line 10 def secret_key @secret_key end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
11 12 13 |
# File 'lib/aws4/signer.rb', line 11 def service @service end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
11 12 13 |
# File 'lib/aws4/signer.rb', line 11 def uri @uri end |
Instance Method Details
#sign(method, uri, headers, body, debug = false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aws4/signer.rb', line 19 def sign(method, uri, headers, body, debug = false) @method = method.upcase @uri = uri @headers = headers @body = body @service = @uri.host.split(".", 2)[0] date_header = headers["Date"] || headers["DATE"] || headers["date"] @date = (date_header ? Time.parse(date_header) : Time.now).utc.strftime(RFC8601BASIC) dump if debug signed = headers.dup signed['Authorization'] = (headers) signed end |