Class: CASServer::Authenticators::ActiveResource

Inherits:
Base
  • Object
show all
Defined in:
lib/casserver/authenticators/active_resource.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #username

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#configure, #extra_attributes

Class Method Details

.setup(options) ⇒ Object

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.

Raises:



61
62
63
64
65
66
67
68
# File 'lib/casserver/authenticators/active_resource.rb', line 61

def self.setup(options)
  raise AuthenticatorError, 'You must define at least site option' unless options[:site]
  # apply options to active resource object
  options.each do |method, arg|
    Helpers::Identity.send "#{method}=", arg if Helpers::Identity.respond_to? "#{method}="
  end
  $LOG.info "ActiveResource configuration loaded"
end

Instance Method Details

#validate(credentials) ⇒ Object

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.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/casserver/authenticators/active_resource.rb', line 77

def validate(credentials)
  begin
    $LOG.debug("Starting Active Resource authentication")
    result = Helpers::Identity.authenticate(credentials.except(:request))
    extract_extra_attributes(result) if result
    !!result
  rescue ::ActiveResource::ConnectionError => e
    if e.response.blank? # band-aid for ARes 2.3.x -- craps out if to_s is called without a response
      e = e.class.to_s
    end
    $LOG.warn("Error during authentication: #{e}")
    false
  end
end