]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - lib/rbot/botuser.rb
4a0fb1336028bc9b8e8d851a789077907ab596e9
[user/henk/code/ruby/rbot.git] / lib / rbot / botuser.rb
1 #-- vim:sw=2:et\r
2 #++\r
3 # :title: User management\r
4 #\r
5 # rbot user management\r
6 # Author:: Giuseppe Bilotta (giuseppe.bilotta@gmail.com)\r
7 # Copyright:: Copyright (c) 2006 Giuseppe Bilotta\r
8 # License:: GPLv2\r
9 \r
10 require 'singleton'\r
11 require 'set'\r
12 \r
13 \r
14 module Irc\r
15 \r
16 \r
17   # This module contains the actual Authentication stuff\r
18   #\r
19   module Auth\r
20 \r
21     BotConfig.register BotConfigStringValue.new( 'auth.password',\r
22       :default => 'rbotauth', :wizard => true,\r
23       :on_change => Proc.new {|bot, v| bot.auth.botowner.password = v},\r
24       :desc => _('Password for the bot owner'))\r
25     BotConfig.register BotConfigBooleanValue.new( 'auth.login_by_mask',\r
26       :default => 'true',\r
27       :desc => _('Set false to prevent new botusers from logging in without a password when the user netmask is known'))\r
28     BotConfig.register BotConfigBooleanValue.new( 'auth.autologin',\r
29       :default => 'true',\r
30       :desc => _('Set false to prevent new botusers from recognizing IRC users without a need to manually login'))\r
31     BotConfig.register BotConfigBooleanValue.new( 'auth.autouser',\r
32       :default => 'false',\r
33       :desc => _('Set true to allow new botusers to be created automatically'))\r
34     # BotConfig.register BotConfigIntegerValue.new( 'auth.default_level',\r
35     #   :default => 10, :wizard => true,\r
36     #   :desc => 'The default level for new/unknown users' )\r
37 \r
38     # Generate a random password of length _l_\r
39     #\r
40     def Auth.random_password(l=8)\r
41       pwd = ""\r
42       l.times do\r
43         pwd << (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr\r
44       end\r
45       return pwd\r
46     end\r
47 \r
48 \r
49     # An Irc::Auth::Command defines a command by its "path":\r
50     #\r
51     #   base::command::subcommand::subsubcommand::subsubsubcommand\r
52     #\r
53     class Command\r
54 \r
55       attr_reader :command, :path\r
56 \r
57       # A method that checks if a given _cmd_ is in a form that can be\r
58       # reduced into a canonical command path, and if so, returns it\r
59       #\r
60       def sanitize_command_path(cmd)\r
61         pre = cmd.to_s.downcase.gsub(/^\*?(?:::)?/,"").gsub(/::$/,"")\r
62         return pre if pre.empty?\r
63         return pre if pre =~ /^\S+(::\S+)*$/\r
64         raise TypeError, "#{cmd.inspect} is not a valid command"\r
65       end\r
66 \r
67       # Creates a new Command from a given string; you can then access\r
68       # the command as a symbol with the :command method and the whole\r
69       # path as :path\r
70       #\r
71       #   Command.new("core::auth::save").path => [:"*", :"core", :"core::auth", :"core::auth::save"]\r
72       #\r
73       #   Command.new("core::auth::save").command => :"core::auth::save"\r
74       #\r
75       def initialize(cmd)\r
76         cmdpath = sanitize_command_path(cmd).split('::')\r
77         seq = cmdpath.inject(["*"]) { |list, cmd|\r
78           list << (list.length > 1 ? list.last + "::" : "") + cmd\r
79         }\r
80         @path = seq.map { |k|\r
81           k.to_sym\r
82         }\r
83         @command = path.last\r
84         debug "Created command #{@command.inspect} with path #{@path.pretty_inspect}"\r
85       end\r
86 \r
87       # Returs self\r
88       def to_irc_auth_command\r
89         self\r
90       end\r
91 \r
92     end\r
93 \r
94   end\r
95 \r
96 end\r
97 \r
98 \r
99 class String\r
100 \r
101   # Returns an Irc::Auth::Comand from the receiver\r
102   def to_irc_auth_command\r
103     Irc::Auth::Command.new(self)\r
104   end\r
105 \r
106 end\r
107 \r
108 \r
109 class Symbol\r
110 \r
111   # Returns an Irc::Auth::Comand from the receiver\r
112   def to_irc_auth_command\r
113     Irc::Auth::Command.new(self)\r
114   end\r
115 \r
116 end\r
117 \r
118 \r
119 module Irc\r
120 \r
121 \r
122   module Auth\r
123 \r
124 \r
125     # This class describes a permission set\r
126     class PermissionSet\r
127 \r
128       attr_reader :perm\r
129       # Create a new (empty) PermissionSet\r
130       #\r
131       def initialize\r
132         @perm = {}\r
133       end\r
134 \r
135       # Inspection simply inspects the internal hash\r
136       def inspect\r
137         @perm.inspect\r
138       end\r
139 \r
140       # Sets the permission for command _cmd_ to _val_,\r
141       #\r
142       def set_permission(str, val)\r
143         cmd = str.to_irc_auth_command\r
144         case val\r
145         when true, false\r
146           @perm[cmd.command] = val\r
147         when nil\r
148           @perm.delete(cmd.command)\r
149         else\r
150           raise TypeError, "#{val.inspect} must be true or false" unless [true,false].include?(val)\r
151         end\r
152       end\r
153 \r
154       # Resets the permission for command _cmd_\r
155       #\r
156       def reset_permission(cmd)\r
157         set_permission(cmd, nil)\r
158       end\r
159 \r
160       # Tells if command _cmd_ is permitted. We do this by returning\r
161       # the value of the deepest Command#path that matches.\r
162       #\r
163       def permit?(str)\r
164         cmd = str.to_irc_auth_command\r
165         allow = nil\r
166         cmd.path.reverse.each { |k|\r
167           if @perm.has_key?(k)\r
168             allow = @perm[k]\r
169             break\r
170           end\r
171         }\r
172         return allow\r
173       end\r
174 \r
175     end\r
176 \r
177 \r
178     # This is the error that gets raised when an invalid password is met\r
179     #\r
180     class InvalidPassword < RuntimeError\r
181     end\r
182 \r
183 \r
184     # This is the basic class for bot users: they have a username, a password,\r
185     # a list of netmasks to match against, and a list of permissions.\r
186     #\r
187     class BotUser\r
188 \r
189       attr_reader :username\r
190       attr_reader :password\r
191       attr_reader :netmasks\r
192       attr_reader :perm\r
193       attr_writer :login_by_mask\r
194       attr_writer :autologin\r
195       attr_accessor :transient\r
196 \r
197       # Create a new BotUser with given username\r
198       def initialize(username, options={})\r
199         opts = {:transient => false}.merge(options)\r
200         @transient = opts[:transient]\r
201         @username = @transient ? "*" : ""\r
202         @username << BotUser.sanitize_username(username)\r
203         @password = nil\r
204         @netmasks = NetmaskList.new\r
205         @perm = {}\r
206         reset_login_by_mask\r
207         reset_autologin\r
208       end\r
209 \r
210       # Inspection\r
211       def inspect\r
212         str = "<#{self.class}:#{'0x%08x' % self.object_id}:"\r
213         str << " @username=#{@username.inspect}"\r
214         str << " @netmasks=#{@netmasks.inspect}"\r
215         str << " @perm=#{@perm.inspect}"\r
216         str << " @login_by_mask=#{@login_by_mask}"\r
217         str << " @autologin=#{@autologin}"\r
218         str << ">"\r
219       end\r
220 \r
221       # In strings\r
222       def to_s\r
223         @username\r
224       end\r
225 \r
226       # Convert into a hash\r
227       def to_hash\r
228         {\r
229           :username => @username,\r
230           :password => @password,\r
231           :netmasks => @netmasks,\r
232           :perm => @perm,\r
233           :login_by_mask => @login_by_mask,\r
234           :autologin => @autologin\r
235         }\r
236       end\r
237 \r
238       # Do we allow logging in without providing the password?\r
239       #\r
240       def login_by_mask?\r
241         @login_by_mask\r
242       end\r
243 \r
244       # Reset the login-by-mask option\r
245       #\r
246       def reset_login_by_mask\r
247         @login_by_mask = Auth.authmanager.bot.config['auth.login_by_mask'] unless defined?(@login_by_mask)\r
248       end\r
249 \r
250       # Reset the autologin option\r
251       #\r
252       def reset_autologin\r
253         @autologin = Auth.authmanager.bot.config['auth.autologin'] unless defined?(@autologin)\r
254       end\r
255 \r
256       # Do we allow automatic logging in?\r
257       #\r
258       def autologin?\r
259         @autologin\r
260       end\r
261 \r
262       # Restore from hash\r
263       def from_hash(h)\r
264         @username = h[:username] if h.has_key?(:username)\r
265         @password = h[:password] if h.has_key?(:password)\r
266         @netmasks = h[:netmasks] if h.has_key?(:netmasks)\r
267         @perm = h[:perm] if h.has_key?(:perm)\r
268         @login_by_mask = h[:login_by_mask] if h.has_key?(:login_by_mask)\r
269         @autologin = h[:autologin] if h.has_key?(:autologin)\r
270       end\r
271 \r
272       # This method sets the password if the proposed new password\r
273       # is valid\r
274       def password=(pwd=nil)\r
275         pass = pwd.to_s\r
276         if pass.empty?\r
277           reset_password\r
278         else\r
279           begin\r
280             raise InvalidPassword, "#{pass} contains invalid characters" if pass !~ /^[\x21-\x7e]+$/\r
281             raise InvalidPassword, "#{pass} too short" if pass.length < 4\r
282             @password = pass\r
283           rescue InvalidPassword => e\r
284             raise e\r
285           rescue => e\r
286             raise InvalidPassword, "Exception #{e.inspect} while checking #{pass.inspect} (#{pwd.inspect})"\r
287           end\r
288         end\r
289       end\r
290 \r
291       # Resets the password by creating a new onw\r
292       def reset_password\r
293         @password = Auth.random_password\r
294       end\r
295 \r
296       # Sets the permission for command _cmd_ to _val_ on channel _chan_\r
297       #\r
298       def set_permission(cmd, val, chan="*")\r
299         k = chan.to_s.to_sym\r
300         @perm[k] = PermissionSet.new unless @perm.has_key?(k)\r
301         @perm[k].set_permission(cmd, val)\r
302       end\r
303 \r
304       # Resets the permission for command _cmd_ on channel _chan_\r
305       #\r
306       def reset_permission(cmd, chan ="*")\r
307         set_permission(cmd, nil, chan)\r
308       end\r
309 \r
310       # Checks if BotUser is allowed to do something on channel _chan_,\r
311       # or on all channels if _chan_ is nil\r
312       #\r
313       def permit?(cmd, chan=nil)\r
314         if chan\r
315           k = chan.to_s.to_sym\r
316         else\r
317           k = :*\r
318         end\r
319         allow = nil\r
320         if @perm.has_key?(k)\r
321           allow = @perm[k].permit?(cmd)\r
322         end\r
323         return allow\r
324       end\r
325 \r
326       # Adds a Netmask\r
327       #\r
328       def add_netmask(mask)\r
329         @netmasks << mask.to_irc_netmask\r
330       end\r
331 \r
332       # Removes a Netmask\r
333       #\r
334       def delete_netmask(mask)\r
335         m = mask.to_irc_netmask\r
336         @netmasks.delete(m)\r
337       end\r
338 \r
339       # Removes all <code>Netmask</code>s\r
340       #\r
341       def reset_netmasks\r
342         @netmasks = NetmaskList.new\r
343       end\r
344 \r
345       # This method checks if BotUser has a Netmask that matches _user_\r
346       #\r
347       def knows?(usr)\r
348         user = usr.to_irc_user\r
349         known = false\r
350         @netmasks.each { |n|\r
351           if user.matches?(n)\r
352             known = true\r
353             break\r
354           end\r
355         }\r
356         return known\r
357       end\r
358 \r
359       # This method gets called when User _user_ wants to log in.\r
360       # It returns true or false depending on whether the password\r
361       # is right. If it is, the Netmask of the user is added to the\r
362       # list of acceptable Netmask unless it's already matched.\r
363       def login(user, password=nil)\r
364         if password == @password or (password.nil? and (@login_by_mask || @autologin) and knows?(user))\r
365           add_netmask(user) unless knows?(user)\r
366           debug "#{user} logged in as #{self.inspect}"\r
367           return true\r
368         else\r
369           return false\r
370         end\r
371       end\r
372 \r
373       # # This method gets called when User _user_ has logged out as this BotUser\r
374       # def logout(user)\r
375       #   delete_netmask(user) if knows?(user)\r
376       # end\r
377 \r
378       # This method sanitizes a username by chomping, downcasing\r
379       # and replacing any nonalphanumeric character with _\r
380       #\r
381       def BotUser.sanitize_username(name)\r
382         candidate = name.to_s.chomp.downcase.gsub(/[^a-z0-9]/,"_")\r
383         raise "sanitized botusername #{candidate} too short" if candidate.length < 3\r
384         return candidate\r
385       end\r
386 \r
387     end\r
388 \r
389     # A TransientBotUser is a BotUser that is not intended\r
390     # for permanent storage. A TransientBotUser must be\r
391     # created with an associated Netmask or User. In the former\r
392     # case the Netmask is added to BotUser's known masks, in the\r
393     # latter the nick part is gobbled and so are the initial\r
394     # nonletter parts of the user.\r
395     #\r
396     class TransientBotUser < BotUser\r
397       def initialize(mask_or_user)\r
398         super(object_id, :transient => true)\r
399         reset_password\r
400         mask = Netmask.new(mask_or_user)\r
401         if User === mask_or_user\r
402           mask.nick = "*"\r
403           mask.host = mask_or_user.host.dup\r
404           mask.user = "*" + mask_or_user.user.sub(/^[^\w]+/,'')\r
405         end\r
406         add_netmask(mask)\r
407         login_by_mask=true\r
408         autologin=true\r
409       end\r
410     end\r
411 \r
412     # This is the default BotUser: it's used for all users which haven't\r
413     # identified with the bot\r
414     #\r
415     class DefaultBotUserClass < BotUser\r
416 \r
417       private :add_netmask, :delete_netmask\r
418 \r
419       include Singleton\r
420 \r
421       # The default BotUser is named 'everyone'\r
422       #\r
423       def initialize\r
424         reset_login_by_mask\r
425         reset_autologin\r
426         super("everyone")\r
427         @default_perm = PermissionSet.new\r
428       end\r
429 \r
430       # This method returns without changing anything\r
431       #\r
432       def login_by_mask=(val)\r
433         debug "Tried to change the login-by-mask for default bot user, ignoring"\r
434         return @login_by_mask\r
435       end\r
436 \r
437       # The default botuser allows logins by mask\r
438       #\r
439       def reset_login_by_mask\r
440         @login_by_mask = true\r
441       end\r
442 \r
443       # This method returns without changing anything\r
444       #\r
445       def autologin=(val)\r
446         debug "Tried to change the autologin for default bot user, ignoring"\r
447         return\r
448       end\r
449 \r
450       # The default botuser doesn't allow autologin (meaningless)\r
451       #\r
452       def reset_autologin\r
453         @autologin = false\r
454       end\r
455 \r
456       # Sets the default permission for the default user (i.e. the ones\r
457       # set by the BotModule writers) on all channels\r
458       #\r
459       def set_default_permission(cmd, val)\r
460         @default_perm.set_permission(Command.new(cmd), val)\r
461         debug "Default permissions now: #{@default_perm.pretty_inspect}"\r
462       end\r
463 \r
464       # default knows everybody\r
465       #\r
466       def knows?(user)\r
467         return true if user.to_irc_user\r
468       end\r
469 \r
470       # We always allow logging in as the default user\r
471       def login(user, password)\r
472         return true\r
473       end\r
474 \r
475       # Resets the NetmaskList\r
476       def reset_netmasks\r
477         super\r
478         add_netmask("*!*@*")\r
479       end\r
480 \r
481       # DefaultBotUser will check the default_perm after checking\r
482       # the global ones\r
483       # or on all channels if _chan_ is nil\r
484       #\r
485       def permit?(cmd, chan=nil)\r
486         allow = super(cmd, chan)\r
487         if allow.nil? && chan.nil?\r
488           allow = @default_perm.permit?(cmd)\r
489         end\r
490         return allow\r
491       end\r
492 \r
493     end\r
494 \r
495     # Returns the only instance of DefaultBotUserClass\r
496     #\r
497     def Auth.defaultbotuser\r
498       return DefaultBotUserClass.instance\r
499     end\r
500 \r
501     # This is the BotOwner: he can do everything\r
502     #\r
503     class BotOwnerClass < BotUser\r
504 \r
505       include Singleton\r
506 \r
507       def initialize\r
508         @login_by_mask = false\r
509         @autologin = true\r
510         super("owner")\r
511       end\r
512 \r
513       def permit?(cmd, chan=nil)\r
514         return true\r
515       end\r
516 \r
517     end\r
518 \r
519     # Returns the only instance of BotOwnerClass\r
520     #\r
521     def Auth.botowner\r
522       return BotOwnerClass.instance\r
523     end\r
524 \r
525 \r
526     # This is the AuthManagerClass singleton, used to manage User/BotUser connections and\r
527     # everything\r
528     #\r
529     class AuthManagerClass\r
530 \r
531       include Singleton\r
532 \r
533       attr_reader :everyone\r
534       attr_reader :botowner\r
535       attr_reader :bot\r
536 \r
537       # The instance manages two <code>Hash</code>es: one that maps\r
538       # <code>Irc::User</code>s onto <code>BotUser</code>s, and the other that maps\r
539       # usernames onto <code>BotUser</code>\r
540       def initialize\r
541         @everyone = Auth::defaultbotuser\r
542         @botowner = Auth::botowner\r
543         bot_associate(nil)\r
544       end\r
545 \r
546       def bot_associate(bot)\r
547         raise "Cannot associate with a new bot! Save first" if defined?(@has_changes) && @has_changes\r
548 \r
549         reset_hashes\r
550 \r
551         # Associated bot\r
552         @bot = bot\r
553 \r
554         # This variable is set to true when there have been changes\r
555         # to the botusers list, so that we know when to save\r
556         @has_changes = false\r
557       end\r
558 \r
559       def set_changed\r
560         @has_changes = true\r
561       end\r
562 \r
563       def reset_changed\r
564         @has_changes = false\r
565       end\r
566 \r
567       def changed?\r
568         @has_changes\r
569       end\r
570 \r
571       # resets the hashes\r
572       def reset_hashes\r
573         @botusers = Hash.new\r
574         @allbotusers = Hash.new\r
575         [everyone, botowner].each { |x|\r
576           @allbotusers[x.username.to_sym] = x\r
577         }\r
578         @transients = Set.new\r
579       end\r
580 \r
581       def load_array(ary, forced)\r
582         unless ary\r
583           warning "Tried to load an empty array"\r
584           return\r
585         end\r
586         raise "Won't load with unsaved changes" if @has_changes and not forced\r
587         reset_hashes\r
588         ary.each { |x|\r
589           raise TypeError, "#{x} should be a Hash" unless x.kind_of?(Hash)\r
590           u = x[:username]\r
591           unless include?(u)\r
592             create_botuser(u)\r
593           end\r
594           get_botuser(u).from_hash(x)\r
595           get_botuser(u).transient = false\r
596         }\r
597         @has_changes=false\r
598       end\r
599 \r
600       def save_array\r
601         @allbotusers.values.map { |x|\r
602           x.transient ? nil : x.to_hash\r
603         }.compact\r
604       end\r
605 \r
606       # checks if we know about a certain BotUser username\r
607       def include?(botusername)\r
608         @allbotusers.has_key?(botusername.to_sym)\r
609       end\r
610 \r
611       # Maps <code>Irc::User</code> to BotUser\r
612       def irc_to_botuser(ircuser)\r
613         logged = @botusers[ircuser.to_irc_user]\r
614         return logged if logged\r
615         return autologin(ircuser)\r
616       end\r
617 \r
618       # creates a new BotUser\r
619       def create_botuser(name, password=nil)\r
620         n = BotUser.sanitize_username(name)\r
621         k = n.to_sym\r
622         raise "botuser #{n} exists" if include?(k)\r
623         bu = BotUser.new(n)\r
624         bu.password = password\r
625         @allbotusers[k] = bu\r
626         return bu\r
627       end\r
628 \r
629       # returns the botuser with name _name_\r
630       def get_botuser(name)\r
631         @allbotusers.fetch(BotUser.sanitize_username(name).to_sym)\r
632       end\r
633 \r
634       # Logs Irc::User _user_ in to BotUser _botusername_ with password _pwd_\r
635       #\r
636       # raises an error if _botusername_ is not a known BotUser username\r
637       #\r
638       # It is possible to autologin by Netmask, on request\r
639       #\r
640       def login(user, botusername, pwd=nil)\r
641         ircuser = user.to_irc_user\r
642         n = BotUser.sanitize_username(botusername)\r
643         k = n.to_sym\r
644         raise "No such BotUser #{n}" unless include?(k)\r
645         if @botusers.has_key?(ircuser)\r
646           return true if @botusers[ircuser].username == n\r
647           # TODO\r
648           # @botusers[ircuser].logout(ircuser)\r
649         end\r
650         bu = @allbotusers[k]\r
651         if bu.login(ircuser, pwd)\r
652           @botusers[ircuser] = bu\r
653           return true\r
654         end\r
655         return false\r
656       end\r
657 \r
658       # Tries to auto-login Irc::User _user_ by looking at the known botusers that allow autologin\r
659       # and trying to login without a password\r
660       #\r
661       def autologin(user)\r
662         ircuser = user.to_irc_user\r
663         debug "Trying to autologin #{ircuser}"\r
664         return @botusers[ircuser] if @botusers.has_key?(ircuser)\r
665         @allbotusers.each { |n, bu|\r
666           debug "Checking with #{n}"\r
667           return bu if bu.autologin? and login(ircuser, n)\r
668         }\r
669         # Check with transient users\r
670         @transients.each { |bu|\r
671           return bu if bu.login(ircuser)\r
672         }\r
673         # Finally, create a transient if we're set to allow it\r
674         if @bot.config['auth.autouser']\r
675           bu = create_transient_botuser(ircuser)\r
676           return bu\r
677         end\r
678         return everyone\r
679       end\r
680 \r
681       # Creates a new transient BotUser associated with Irc::User _user_,\r
682       # automatically logging him in\r
683       #\r
684       def create_transient_botuser(user)\r
685         ircuser = user.to_irc_user\r
686         bu = TransientBotUser.new(ircuser)\r
687         bu.login(ircuser)\r
688         @transients << bu\r
689         return bu\r
690       end\r
691 \r
692       # Checks if User _user_ can do _cmd_ on _chan_.\r
693       #\r
694       # Permission are checked in this order, until a true or false\r
695       # is returned:\r
696       # * associated BotUser on _chan_\r
697       # * associated BotUser on all channels\r
698       # * everyone on _chan_\r
699       # * everyone on all channels\r
700       #\r
701       def permit?(user, cmdtxt, channel=nil)\r
702         if user.class <= BotUser\r
703           botuser = user\r
704         else\r
705           botuser = irc_to_botuser(user)\r
706         end\r
707         cmd = cmdtxt.to_irc_auth_command\r
708 \r
709         chan = channel\r
710         case chan\r
711         when User\r
712           chan = "?"\r
713         when Channel\r
714           chan = chan.name\r
715         end\r
716 \r
717         allow = nil\r
718 \r
719         allow = botuser.permit?(cmd, chan) if chan\r
720         return allow unless allow.nil?\r
721         allow = botuser.permit?(cmd)\r
722         return allow unless allow.nil?\r
723 \r
724         unless botuser == everyone\r
725           allow = everyone.permit?(cmd, chan) if chan\r
726           return allow unless allow.nil?\r
727           allow = everyone.permit?(cmd)\r
728           return allow unless allow.nil?\r
729         end\r
730 \r
731         raise "Could not check permission for user #{user.inspect} to run #{cmdtxt.inspect} on #{chan.inspect}"\r
732       end\r
733 \r
734       # Checks if command _cmd_ is allowed to User _user_ on _chan_, optionally\r
735       # telling if the user is authorized\r
736       #\r
737       def allow?(cmdtxt, user, chan=nil)\r
738         if permit?(user, cmdtxt, chan)\r
739           return true\r
740         else\r
741           # cmds = cmdtxt.split('::')\r
742           # @bot.say chan, "you don't have #{cmds.last} (#{cmds.first}) permissions here" if chan\r
743           @bot.say chan, _("%{user}, you don't have '%{command}' permissions here") %\r
744                         {:user=>user, :command=>cmdtxt} if chan\r
745           return false\r
746         end\r
747       end\r
748 \r
749     end\r
750 \r
751     # Returns the only instance of AuthManagerClass\r
752     #\r
753     def Auth.authmanager\r
754       return AuthManagerClass.instance\r
755     end\r
756 \r
757   end\r
758 \r
759 end\r