Method: ActionController::HttpAuthentication::Token#authentication_request

Defined in:
actionpack/lib/action_controller/metal/http_authentication.rb

#authentication_request(controller, realm, message = nil) ⇒ Object

Sets a WWW-Authenticate header to let the client know a token is desired.

Returns nothing.

#### Parameters

  • controller - ActionController::Base instance for the outgoing response.

  • realm - String realm to use in the header.



555
556
557
558
559
# File 'actionpack/lib/action_controller/metal/http_authentication.rb', line 555

def authentication_request(controller, realm, message = nil)
  message ||= "HTTP Token: Access denied.\n"
  controller.headers["WWW-Authenticate"] = %(Token realm="#{realm.tr('"', "")}")
  controller.__send__ :render, plain: message, status: :unauthorized
end