Class: MAuth::Rack::ResponseSigner

Inherits:
Middleware show all
Defined in:
lib/mauth/rack.rb

Overview

signs outgoing responses with only the protocol used to sign the request.

Instance Method Summary collapse

Methods inherited from Middleware

#initialize, #mauth_client

Constructor Details

This class inherits a constructor from MAuth::Middleware

Instance Method Details

#call(env) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/mauth/rack.rb', line 97

def call(env)
  unsigned_response = @app.call(env)

  method =
    case env['mauth.protocol_version']
    when 2
      :signed_v2
    when 1
      :signed_v1
    else
      # if no protocol was supplied then use `signed` which either signs
      # with both protocol versions (by default) or only v2 when the
      # v2_only_sign_requests flag is set to true.
      :signed
    end
  response = mauth_client.send(method, MAuth::Rack::Response.new(*unsigned_response))
  response.status_headers_body
end