method
authenticate_or_request_with_http_basic
v3.0.9 -
Show latest stable
- Class:
ActionController::HttpAuthentication::Basic::ControllerMethods
authenticate_or_request_with_http_basic(realm = "Application", &login_procedure)public
No documentation available.
# File actionpack/lib/action_controller/metal/http_authentication.rb, line 113
def authenticate_or_request_with_http_basic(realm = "Application", &login_procedure)
authenticate_with_http_basic(&login_procedure) || request_http_basic_authentication(realm)
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.