Method: WEBrick::HTTPAuth.basic_auth

Defined in:
lib/webrick/httpauth.rb

.basic_auth(req, res, realm, &block) ⇒ Object

Simple wrapper for providing basic authentication for a request. When called with a request req, response res, authentication realm and block the block will be called with a username and password. If the block returns true the request is allowed to continue, otherwise an HTTPStatus::Unauthorized error is raised.



79
80
81
82
# File 'lib/webrick/httpauth.rb', line 79

def basic_auth(req, res, realm, &block) # :yield: username, password
  _basic_auth(req, res, realm, "Authorization", "WWW-Authenticate",
              HTTPStatus::Unauthorized, block)
end