method
authenticate_or_request_with_http_basic
rails latest stable - Class:
ActionController::HttpAuthentication::Basic::ControllerMethods
authenticate_or_request_with_http_basic(realm = nil, message = nil, &login_procedure)public
No documentation available.
# File actionpack/lib/action_controller/metal/http_authentication.rb, line 92
def authenticate_or_request_with_http_basic(realm = nil, message = nil, &login_procedure)
authenticate_with_http_basic(&login_procedure) || request_http_basic_authentication(realm || "Application", message)
end 1Note
Testing protected controllers
When testing controllers which are protected with #authenticate_or_request_with_http_basic this is how you can supply the credentials for a successful login:
@request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
Must be set before the request is sent through #get or whatever method.