Module: RackStep::Controller::BasicHttpAuthentication

Defined in:
lib/controller.rb

Overview

A module for controllers to add basic http authentication helper method.

Instance Method Summary collapse

Instance Method Details

#basic_access_authentication_credentialsObject



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/controller.rb', line 80

def basic_access_authentication_credentials
  credentials = nil
  # Trying to get the basic http authentication credentials from the request.
  auth = Rack::Auth::Basic::Request.new(request.env)
  if auth.provided? and auth.basic? and auth.credentials
    credentials = auth.credentials
  else
    # No credentials found. Will return empty to avoid returning nil.
    credentials = ['', '']
  end

  return credentials
end