Class: AWS4Signer
- Inherits:
-
Object
- Object
- AWS4Signer
- Defined in:
- lib/activemessaging/adapters/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) ⇒ AWS4Signer
constructor
A new instance of AWS4Signer.
- #sign(method, uri, headers, body = nil, debug = false, service_name = nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ AWS4Signer
Returns a new instance of AWS4Signer.
24 25 26 27 28 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 24 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.
21 22 23 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 21 def access_key @access_key end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
22 23 24 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 22 def body @body end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
22 23 24 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 22 def date @date end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
22 23 24 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 22 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
22 23 24 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 22 def method @method end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
21 22 23 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 21 def region @region end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
21 22 23 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 21 def secret_key @secret_key end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
22 23 24 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 22 def service @service end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
22 23 24 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 22 def uri @uri end |
Instance Method Details
#sign(method, uri, headers, body = nil, debug = false, service_name = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/activemessaging/adapters/aws4_signer.rb', line 30 def sign(method, uri, headers, body = nil, debug = false, service_name=nil) @method = method.upcase @uri = uri @headers = headers @body = body @service = service_name || @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 |