Skip to Content Skip to Search
Methods
H

Instance Public methods

http_basic_authenticate_with(name:, password:, realm: nil, message: nil, content_type: nil, **options)

Enables HTTP Basic authentication.

See ActionController::HttpAuthentication::Basic for example usage.

# File actionpack/lib/action_controller/metal/http_authentication.rb, line 81
def http_basic_authenticate_with(name:, password:, realm: nil, message: nil, content_type: nil, **options)
  raise ArgumentError, "Expected name: to be a String, got #{name.class}" unless name.is_a?(String)
  raise ArgumentError, "Expected password: to be a String, got #{password.class}" unless password.is_a?(String)

  if password.blank?
    ActionController.deprecator.warn(BLANK_PASSWORD_DEPRECATION % __method__)
  end

  before_action(options) { authenticate_or_request_with_http_basic_credentials(name, password, realm, message, content_type) }
end