Module: CASServer::Authenticators::SQLRestAuth::EncryptedPassword

Defined in:
lib/casserver/authenticators/sql_rest_auth.rb

Constant Summary collapse

REST_AUTH_DIGEST_STRETCHES =

XXX: this constants MUST be defined in config. For more details # look at restful-authentication docs.

$CONF.rest_auth_digest_streches
REST_AUTH_SITE_KEY =
$CONF.rest_auth_site_key

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



51
52
53
# File 'lib/casserver/authenticators/sql_rest_auth.rb', line 51

def self.included(mod)
  raise "#{self} should be inclued in an ActiveRecord class!" unless mod.respond_to?(:before_save)
end

Instance Method Details

#encrypt(password) ⇒ Object



55
56
57
# File 'lib/casserver/authenticators/sql_rest_auth.rb', line 55

def encrypt(password)
  password_digest(password, self.salt)
end

#password_digest(password, salt) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/casserver/authenticators/sql_rest_auth.rb', line 63

def password_digest(password, salt)
  digest = REST_AUTH_SITE_KEY
  REST_AUTH_DIGEST_STRETCHES.times do
    digest = secure_digest(digest, salt, password, REST_AUTH_SITE_KEY)
  end
  digest
end

#secure_digest(*args) ⇒ Object



59
60
61
# File 'lib/casserver/authenticators/sql_rest_auth.rb', line 59

def secure_digest(*args)
  Digest::SHA1.hexdigest(args.flatten.join('--'))
end