Class: Rack::SimpleAuth::HMAC::Middleware
- Inherits:
-
Object
- Object
- Rack::SimpleAuth::HMAC::Middleware
- Defined in:
- lib/rack/simple_auth/hmac/middleware.rb
Overview
Middleware class which represents the interface to the rack api via #call and checks if a request is hmac authorized.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Rack API Interface Method.
-
#call!(env) ⇒ Object
call! Method.
-
#initialize(app) {|@config| ... } ⇒ Middleware
constructor
Constructor for Rack Middleware (passing the rack stack).
Constructor Details
#initialize(app) {|@config| ... } ⇒ Middleware
Constructor for Rack Middleware (passing the rack stack)
38 39 40 41 42 |
# File 'lib/rack/simple_auth/hmac/middleware.rb', line 38 def initialize(app) @app, @config = app, Config.new yield @config if block_given? end |
Instance Method Details
#call(env) ⇒ Object
Rack API Interface Method
49 50 51 52 |
# File 'lib/rack/simple_auth/hmac/middleware.rb', line 49 def call(env) # self.dup.call!(env) dup.call!(env) end |
#call!(env) ⇒ Object
call! Method
59 60 61 62 63 64 65 66 67 68 69 |
# 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 |