Module: QuickAuth::Authentic::ClassMethods

Defined in:
lib/quick_auth/authentic.rb

Instance Method Summary collapse

Instance Method Details

#digest(password, salt) ⇒ Object



40
41
42
43
44
# File 'lib/quick_auth/authentic.rb', line 40

def digest(password, salt)
	dig = [password, salt].flatten.join('')
	20.times { dig = Digest::SHA512.hexdigest(dig) }
	dig
end

#find_using_perishable_token(token) ⇒ Object



22
23
24
# File 'lib/quick_auth/authentic.rb', line 22

def find_using_perishable_token(token)
  u = self.first(:conditions => {:phtk => token, :phtke.gt => Time.now})
end

#friendly_tokenObject



46
47
48
49
# File 'lib/quick_auth/authentic.rb', line 46

def friendly_token
	# use base64url as defined by RFC4648
	SecureRandom.base64(15).tr('+/=', '').strip.delete("\n")
end

#quick_auth_mongo_keys!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/quick_auth/authentic.rb', line 26

def quick_auth_mongo_keys!
	key :crp,   String    # crypted password
	key :pws,   String    # password salt
	key :pstk,  String    # persistant token
	key :phtk,  String    # perishable token
	key :phtke, Time      # perishable token expiration
			
	attr_alias :crypted_password,   :crp
	attr_alias :password_salt,      :pws
	attr_alias :persistent_token,   :pstk
	attr_alias :perishable_token,   :phtk
	attr_alias :perishable_token_exp, :phtke
end