Method: JunglePath::Rack::BasicCredentials::Basic#call

Defined in:
lib/jungle_path/rack/basic_credentials.rb

#call(env) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jungle_path/rack/basic_credentials.rb', line 23

def call(env)
  #puts "realm: #{realm}."

  auth = Basic::Request.new(env)

  if @issue_challenge
    return unauthorized unless auth.provided?
    return bad_request unless auth.basic?
  end

  if auth.provided? and auth.basic?
    env['REMOTE_USER'] = auth.username
    env['REMOTE_PASSWORD'] = auth.password
  else
    env['REMOTE_USER'] = nil
    env['REMOTE_PASSWORD'] = nil
  end

  @app.call(env)
end