class Rails::Auth::Credentials::InjectorMiddleware

A middleware for injecting an arbitrary credentials hash into the Rack environment This is intended for development and testing purposes where you would like to simulate a given X.509 certificate being used in a request or user logged in. The credentials argument should either be a hash or a proc that returns one.

Public Class Methods

new(app, credentials) click to toggle source
# File lib/rails/auth/credentials/injector_middleware.rb, line 11
def initialize(app, credentials)
  @app = app
  @credentials = credentials
end

Public Instance Methods

call(env) click to toggle source
# File lib/rails/auth/credentials/injector_middleware.rb, line 16
def call(env)
  credentials = @credentials.respond_to?(:call) ? @credentials.call(env) : @credentials
  env[Rails::Auth::Env::CREDENTIALS_ENV_KEY] = credentials
  @app.call(env)
end