Class: MAuth::Faraday::ResponseAuthenticator

Inherits:
Middleware
  • Object
show all
Defined in:
lib/mauth/faraday.rb

Overview

faraday middleware to authenticate incoming responses

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(request_env) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/mauth/faraday.rb', line 19

def call(request_env)
  @app.call(request_env).on_complete do |response_env|
    mauth_response = MAuth::Faraday::Response.new(response_env)
    mauth_client.authenticate!(mauth_response) # raises MAuth::InauthenticError when inauthentic
    response_env['mauth.app_uuid'] = mauth_response.signature_app_uuid
    response_env['mauth.authentic'] = true
    response_env
  end
end