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



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mauth/rack.rb', line 94

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

  method =
    if env['mauth.protocol_version'] == 2
      :signed_v2
    elsif env['mauth.protocol_version'] == 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