Class: Rack::Authenticate::Middleware

Inherits:
Rack::Auth::Basic
  • Object
show all
Defined in:
lib/rack/authenticate/middleware.rb

Defined Under Namespace

Classes: Auth, Configuration

Instance Method Summary collapse

Constructor Details

#initialize(app) {|@configuration| ... } ⇒ Middleware

Returns a new instance of Middleware.

Yields:

  • (@configuration)


121
122
123
124
125
# File 'lib/rack/authenticate/middleware.rb', line 121

def initialize(app)
  @configuration = Configuration.new
  yield @configuration
  super(app, &@configuration.basic_auth_validation_block)
end

Instance Method Details

#call(env) ⇒ Object



127
128
129
130
131
132
133
134
135
136
# File 'lib/rack/authenticate/middleware.rb', line 127

def call(env)
  auth = Auth.new(env, @configuration)
  return unauthorized unless auth.provided?
  return super(env) if auth.basic?
  return bad_request  unless auth.hmac?
  return bad_request  unless auth.has_all_required_parts?
  return unauthorized unless auth.valid?

  @app.call(env)
end