Sha256: 2324409215f4d2c08c27f4f140371d704ac649412f00748a69952481ba296da9
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
require "digest/sha1" module Castronaut module Adapters module RestfulAuthentication class User < ActiveRecord::Base def self.digest(password, salt) site_key = Castronaut.config.cas_adapter['site_key'] digest_value = site_key Castronaut.config.cas_adapter['digest_stretches'].times do digest_value = secure_digest(digest_value, salt, password, site_key) end digest_value end def self.secure_digest(*args) Digest::SHA1.hexdigest(args.flatten.join('--')) end def self.authenticate(username, password) if user = find_by_login(username) if user.crypted_password == Castronaut::Adapters::RestfulAuthentication::User.digest(password, user.salt) Castronaut::AuthenticationResult.new(username, nil) else Castronaut::AuthenticationResult.new(username, "Unable to authenticate the username #{username}") end else Castronaut::AuthenticationResult.new(username, "Unable to authenticate the username #{username}") end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems