Module | WEBrick::HTTPAuth::Authenticator |
In: |
lib/webrick/httpauth/authenticator.rb
|
RequestField | = | "Authorization" |
ResponseField | = | "WWW-Authenticate" |
ResponseInfoField | = | "Authentication-Info" |
AuthException | = | HTTPStatus::Unauthorized |
AuthScheme | = | nil |
logger | [R] | |
realm | [R] | |
userdb | [R] |
# File lib/webrick/httpauth/authenticator.rb, line 23 23: def check_init(config) 24: [:UserDB, :Realm].each{|sym| 25: unless config[sym] 26: raise ArgumentError, "Argument #{sym.inspect} missing." 27: end 28: } 29: @realm = config[:Realm] 30: @userdb = config[:UserDB] 31: @logger = config[:Logger] || Log::new($stderr) 32: @reload_db = config[:AutoReloadUserDB] 33: @request_field = self::class::RequestField 34: @response_field = self::class::ResponseField 35: @resp_info_field = self::class::ResponseInfoField 36: @auth_exception = self::class::AuthException 37: @auth_scheme = self::class::AuthScheme 38: end
# File lib/webrick/httpauth/authenticator.rb, line 40 40: def check_scheme(req) 41: unless credentials = req[@request_field] 42: error("no credentials in the request.") 43: return nil 44: end 45: unless match = /^#{@auth_scheme}\s+/.match(credentials) 46: error("invalid scheme in %s.", credentials) 47: info("%s: %s", @request_field, credentials) if $DEBUG 48: return nil 49: end 50: return match.post_match 51: end
# File lib/webrick/httpauth/authenticator.rb, line 59 59: def error(fmt, *args) 60: if @logger.error? 61: log(:error, fmt, *args) 62: end 63: end
# File lib/webrick/httpauth/authenticator.rb, line 65 65: def info(fmt, *args) 66: if @logger.info? 67: log(:info, fmt, *args) 68: end 69: end