Class CASServer::Authenticators::Base
In: lib/casserver/authenticators/base.rb
Parent: Object

Methods

Attributes

options  [RW] 
username  [R] 

Public Class methods

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.

[Source]

    # File lib/casserver/authenticators/base.rb, line 12
12:       def self.setup(options)
13:       end

Public Instance methods

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.

[Source]

    # 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

[Source]

    # 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.

[Source]

    # 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

Protected Instance methods

[Source]

    # 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

[Source]

    # File lib/casserver/authenticators/base.rb, line 42
42:       def read_standard_credentials(credentials)
43:         @username = credentials[:username]
44:         @password = credentials[:password]
45:         @service = credentials[:service]
46:         @request = credentials[:request]
47:       end

[Validate]