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



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

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::Client::RACK_ENV_APP_UUID_KEY] = mauth_response.signature_app_uuid
    response_env['mauth.authentic'] = true
    response_env
  end
end