An authentication strategy for DRbService – set a password via a class method.
Overridden mixin callback – add the ClassMethods to the including class
# File lib/drbservice/passwordauth.rb, line 28 def self::included( klass ) super klass.extend( ClassMethods ) end
Authenticate using the specified password, calling the provided block if authentication succeeds. Raises a SecurityError if authentication fails. If no password is set, the block is called regardless of what the password is.
# File lib/drbservice/passwordauth.rb, line 37 def authenticate( password ) if digest = self.class.password_digest if Digest::SHA2.hexdigest( password ) == digest self.log.info "authentication successful" @authenticated = true yield else super end else self.log.error "no password set -- authentication will always fail" super end ensure @authenticated = false end
Generated with the Darkfish Rdoc Generator 2.