1#-- 2# httpauth/userdb.rb -- UserDB mix-in module. 3# 4# Author: IPR -- Internet Programming with Ruby -- writers 5# Copyright (c) 2003 Internet Programming with Ruby writers. All rights 6# reserved. 7# 8# $IPR: userdb.rb,v 1.2 2003/02/20 07:15:48 gotoyuzo Exp $ 9 10module WEBrick 11 module HTTPAuth 12 13 ## 14 # User database mixin for HTTPAuth. This mixin dispatches user record 15 # access to the underlying auth_type for this database. 16 17 module UserDB 18 19 ## 20 # The authentication type. 21 # 22 # WEBrick::HTTPAuth::BasicAuth or WEBrick::HTTPAuth::DigestAuth are 23 # built-in. 24 25 attr_accessor :auth_type 26 27 ## 28 # Creates an obscured password in +realm+ with +user+ and +password+ 29 # using the auth_type of this database. 30 31 def make_passwd(realm, user, pass) 32 @auth_type::make_passwd(realm, user, pass) 33 end 34 35 ## 36 # Sets a password in +realm+ with +user+ and +password+ for the 37 # auth_type of this database. 38 39 def set_passwd(realm, user, pass) 40 self[user] = pass 41 end 42 43 ## 44 # Retrieves a password in +realm+ for +user+ for the auth_type of this 45 # database. +reload_db+ is a dummy value. 46 47 def get_passwd(realm, user, reload_db=false) 48 make_passwd(realm, user, self[user]) 49 end 50 end 51 end 52end 53