class Rack::SimpleAuth::HMAC::Middleware
Middleware
class which represents the interface to the rack api via {#call} and checks if a request is hmac authorized.
@example Basic Usage
"request_config = { 'GET' => 'path', 'POST' => 'params', 'DELETE' => 'path', 'PUT' => 'path', 'PATCH' => 'path' } use Rack::SimpleAuth::HMAC::Middleware do |options| options.tolerance = 1500 options.secret = 'test_secret' options.signature = 'test_signature' options.logpath = "#{File.expand_path('..', __FILE__)}/logs" options.request_config = request_config options.verbose = true end run Rack::Lobster.new"
Public Class Methods
new(app) { |config| ... }
click to toggle source
Constructor for Rack
Middleware
(passing the rack stack)
@param [Rack Application] app [next middleware or rack app which gets called]
# File lib/rack/simple_auth/hmac/middleware.rb, line 38 def initialize(app) @app, @config = app, Config.new yield @config if block_given? end
Public Instance Methods
call(env)
click to toggle source
Rack
API Interface Method
@param [Hash] env [Rack Env Hash which contains headers etc..]
# File lib/rack/simple_auth/hmac/middleware.rb, line 49 def call(env) # self.dup.call!(env) dup.call!(env) end
call!(env)
click to toggle source
call! Method
@param [Hash] env [Rack Env Hash which contains headers etc..]
# File lib/rack/simple_auth/hmac/middleware.rb, line 59 def call!(env) env = env.dup request = Request.new(env, @config) if request.valid? @app.call(env) else response = Response.new('Unauthorized', 401, 'Content-Type' => 'text/html') response.finish end end