From 8c2a52937f3b71efa7bcb48e7b8b00bc6b616ab4 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 10 May 2011 23:37:43 +0000 Subject: * lib/webrick: Add documentation for WEBrick::HTTPAuth git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/webrick/httpauth/authenticator.rb | 37 +++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'lib/webrick/httpauth/authenticator.rb') diff --git a/lib/webrick/httpauth/authenticator.rb b/lib/webrick/httpauth/authenticator.rb index af34a19b88..0739d4371d 100644 --- a/lib/webrick/httpauth/authenticator.rb +++ b/lib/webrick/httpauth/authenticator.rb @@ -9,17 +9,43 @@ module WEBrick module HTTPAuth + + ## + # Module providing generic support for both Digest and Basic + # authentication schemes. + module Authenticator + RequestField = "Authorization" ResponseField = "WWW-Authenticate" ResponseInfoField = "Authentication-Info" AuthException = HTTPStatus::Unauthorized - AuthScheme = nil # must override by the derived class - attr_reader :realm, :userdb, :logger + ## + # Method of authentication, must be overriden by the including class + + AuthScheme = nil + + ## + # The realm this authenticator covers + + attr_reader :realm + + ## + # The user database for this authenticator + + attr_reader :userdb + + ## + # The logger for this authenticator + + attr_reader :logger private + ## + # Initializes the authenticator from +config+ + def check_init(config) [:UserDB, :Realm].each{|sym| unless config[sym] @@ -37,6 +63,9 @@ module WEBrick @auth_scheme = self::class::AuthScheme end + ## + # Ensures +req+ has credentials that can be authenticated. + def check_scheme(req) unless credentials = req[@request_field] error("no credentials in the request.") @@ -69,6 +98,10 @@ module WEBrick end end + ## + # Module providing generic support for both Digest and Basic + # authentication schemes for proxies. + module ProxyAuthenticator RequestField = "Proxy-Authorization" ResponseField = "Proxy-Authenticate" -- cgit v1.2.3