Class: Vacuum::Request::Signature::Authentication

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/vacuum/request/signature/authentication.rb

Overview

Internal: Middleware that signs REST requests to various Amazon API endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(app, secret) ⇒ Authentication

Initializes the middleware.

app - An Object that responds to ‘call` and returns a Faraday::Response. secret - The String Amazon AWS access secret key.



12
13
14
15
# File 'lib/vacuum/request/signature/authentication.rb', line 12

def initialize(app, secret)
  @secret = secret
  super app
end

Instance Method Details

#call(env) ⇒ Object

Signs the request.

env - A Hash that contains info about the request.

Returns an Object that responds to ‘call` and returns a Faraday::Response.



23
24
25
26
27
28
# File 'lib/vacuum/request/signature/authentication.rb', line 23

def call(env)
  builder = Builder.new env, @secret
  builder.timestamp.sort_query.sign

  @app.call builder.env
end