Class: Rack::MogueraAuthentication
- Inherits:
-
Object
- Object
- Rack::MogueraAuthentication
- Defined in:
- lib/rack/moguera_authentication.rb
Overview
A Rack middleware inserts a Moguera Authentication.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &block) ⇒ MogueraAuthentication
constructor
A new instance of MogueraAuthentication.
Constructor Details
#initialize(app, &block) ⇒ MogueraAuthentication
Returns a new instance of MogueraAuthentication.
14 15 16 17 |
# File 'lib/rack/moguera_authentication.rb', line 14 def initialize(app, &block) @app = app @secret_block = block end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rack/moguera_authentication.rb', line 19 def call(env) begin request_token = Moguera::Authentication.new(env['HTTP_AUTHORIZATION']) auth = request_token.authenticate! do |access_key| secret_access_key = @secret_block.call(access_key) params = build_parameter(access_key, secret_access_key, env) Moguera::Authentication::Request.new(params) end env['moguera.auth'] = auth rescue => e env['moguera.error'] = e end @app.call(env) end |