still working on the timing attack prevention tutorial
This commit is contained in:
+3
-3
@@ -35,10 +35,10 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
# More secure version, but still lacking a decent hashing routine
|
# More secure version, still lacking a decent hashing routine, this is for timing attack prevention
|
||||||
def self.authenticate(email, password)
|
def self.authenticate(email, password)
|
||||||
user = find_by_email(email)
|
user = find_by_email(email) || User.new(:password => '')
|
||||||
if user and Rack::Utils.secure_compare(user.password, Digest::MD5.hexdigest(password))
|
if Rack::Utils.secure_compare(user.password, Digest::MD5.hexdigest(password))
|
||||||
return user
|
return user
|
||||||
else
|
else
|
||||||
raise "Incorrect username or password"
|
raise "Incorrect username or password"
|
||||||
|
|||||||
Reference in New Issue
Block a user