class ResoTransport::Authentication::Middleware
Authentication
middleware Ensures that each request is made with proper `Authorization` header set and raises an exception if a request yields a `401 Access
Denied` response.
Constants
- AUTH_HEADER
Public Class Methods
new(app, auth)
click to toggle source
Calls superclass method
# File lib/reso_transport/authentication/middleware.rb, line 9 def initialize(app, auth) super(app) @auth = auth end
Public Instance Methods
call(request_env)
click to toggle source
# File lib/reso_transport/authentication/middleware.rb, line 14 def call(request_env) retries = 1 begin authorize_request(request_env) @app.call(request_env).on_complete do |response_env| raise_if_unauthorized(request_env, response_env) end rescue ResoTransport::AccessDenied raise if retries.zero? @auth.reset retries -= 1 retry end end