Class: CASServer::Authenticators::SQLRestAuth

Inherits:
SQLEncrypted show all
Defined in:
lib/casserver/authenticators/sql_rest_auth.rb

Overview

This is a version of the SQL authenticator that works nicely with RestfulAuthentication. Passwords are encrypted the same way as it done in RestfulAuthentication. Before use you this, you MUST configure rest_auth_digest_streches and rest_auth_site_key in config.

Using this authenticator requires restful authentication plugin on rails (client) side.

  • git://github.com/technoweenie/restful-authentication.git

Defined Under Namespace

Modules: EncryptedPassword

Instance Attribute Summary

Attributes inherited from Base

#options, #username

Instance Method Summary collapse

Methods inherited from Base

#configure, #extra_attributes

Instance Method Details

#validate(credentials) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/casserver/authenticators/sql_rest_auth.rb', line 23

def validate(credentials)
  read_standard_credentials(credentials)

  raise CASServer::AuthenticatorError, "Cannot validate credentials because the authenticator hasn't yet been configured" unless @options

  user_model = establish_database_connection_if_necessary

  username_column = @options[:username_column] || "email"

  results = user_model.find(:all, :conditions => ["#{username_column} = ?", @username])

  if results.size > 0
    $LOG.warn("Multiple matches found for user '#{@username}'") if results.size > 1
    user = results.first
    return (user.crypted_password == user.encrypt(@password))
  else
    return false
  end
end