Class | CASServer::Authenticators::Base |
In: |
lib/casserver/authenticators/base.rb
|
Parent: | Object |
options | [RW] | |
username | [R] |
This is called at server startup. Any class-wide initializiation for the authenticator should be done here. (e.g. establish database connection). You can leave this empty if you don‘t need to set up anything.
# File lib/casserver/authenticators/base.rb, line 12 12: def self.setup(options) 13: end
This is called prior to validate (i.e. each time the user tries to log in). Any per-instance initialization for the authenticator should be done here.
By default this makes the authenticator options hash available for validate under @options and initializes @extra_attributes to an empty hash.
# File lib/casserver/authenticators/base.rb, line 20 20: def configure(options) 21: raise ArgumentError, "options must be a HashWithIndifferentAccess" unless options.kind_of? HashWithIndifferentAccess 22: @options = options.dup 23: @extra_attributes = {} 24: end
# File lib/casserver/authenticators/base.rb, line 37 37: def extra_attributes 38: @extra_attributes 39: end
Override this to implement your authentication credential validation. This is called each time the user tries to log in. The credentials hash holds the credentials as entered by the user (generally under :username and :password keys; :service and :request are also included by default)
Note that the standard credentials can be read in to instance variables by calling read_standard_credentials.
# File lib/casserver/authenticators/base.rb, line 33 33: def validate(credentials) 34: raise NotImplementedError, "This method must be implemented by a class extending #{self.class}" 35: end
# File lib/casserver/authenticators/base.rb, line 49 49: def extra_attributes_to_extract 50: if @options[:extra_attributes].kind_of? Array 51: attrs = @options[:extra_attributes] 52: elsif @options[:extra_attributes].kind_of? String 53: attrs = @options[:extra_attributes].split(',').collect{|col| col.strip} 54: else 55: $LOG.error("Can't figure out attribute list from #{@options[:extra_attributes].inspect}. This must be an Aarray of column names or a comma-separated list.") 56: attrs = [] 57: end 58: 59: $LOG.debug("#{self.class.name} will try to extract the following extra_attributes: #{attrs.inspect}") 60: return attrs 61: end