Brain Buster plugin

Plugin details

BrainBuster is a logic captcha for Rails. A logic captcha attempts to detect automated responses (ie spambots) by asking a simple quesiton, such as a word puzzle or math question. Logic captchas are often easier for humans to answer then image based captchas, but can exclude foreign users or users with cognitive disabilities. Another possible issue is that answers could be scripted fairly easily by a determined spammer, but I'm guessing in most cases spammers will move on to easier targets. Generating thousands of questions may also deter scripting.

Websitehttp://robsanheim.com/brain-buster Repositorygit://github.com/rsanheim/brain_buster.git Author Rob Sanheim Tags capcha LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install git://github.com/rsanheim/brain_buster.git

BrainBuster includes a model for storing questions and answers, a module to be mixed in to controllers to help in checking the captcha, a small partial to display the question and input form, and a basic stylesheet for styling the partial. There is also a "captcha_footer" partial that is not functionally required at all, its just included to make it easy to give credit and a little link-love if you find this useful. There are many pieces because this plugin spans all of MVC, but each piece is simple and trivial so overriding or replacing certain parts would be easy.

This captcha is meant to be user-friendly, so for a questions like "What is two plus two", all of the following answers will work: "4", "four", "Four", " four ". By default, a user only needs to answer a captcha _once_, then they are cookied and don't have to answer another question until they close/reopen their browser.

Generate the migration, modifying questions and answers if you wish:

script/generate brain_buster_migration



Copy the style sheet and partials into their appropriate places - this will depend upon your application

cp vendor/plugins/brain_buster/assets/stylesheets/captcha.css public/stylesheets/             
cp vendor/plugins/brain_buster/views/brain_busters/_*.rhtml app/views/shared/



add the style sheet where needed

<%= stylesheet_link_tag 'captcha' %>



Now change any controller(s) you want protected by doing the following:

include the mixin into the controller(s):

    class AccountController
        include BrainBustersMixin
        ...



add the before filter to find a captcha question for any actions that need to display a question (ie the challenge to the user):

class AccountController
        include BrainBustersMixin

        # we need to display captcha questions for the new and index actions
        before_filter BrainBustersFilter, :only => [:new, :index] 
        ...



render the partial in appropriate templates
- new.rhtml:

      ... inside your form somewhere
      <%= render :partial => 'shared/captcha' %> 
      <%= render :partial => "shared/captcha_footer" %>



* add a call to the "captcha_passed?" method which actually checks the answer against the question and returns true if the answer matches

  class AccountController
      ...
      def create
          unless captcha_passed?
            redirect to :action => 'new' and return
          end
          ## normal create processing follows...
          @account = Account.new(params[:account])
          ## etc...
      end
      ...

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, about 1 month ago