module RackStep::Controller::BasicHttpAuthentication

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

Public Instance Methods

basic_access_authentication_credentials() click to toggle source
# 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