diff options
Diffstat (limited to 'lib/webrick/httpauth/authenticator.rb')
-rw-r--r-- | lib/webrick/httpauth/authenticator.rb | 37 |
1 files changed, 35 insertions, 2 deletions
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" |