reCAPTCHA your Rails Application !
2
CAPTCHA stands for "Completely Automated Public Turing test to tell Computers and Humans Apart". As the acronym suggests, the main reason of using CAPTCHA is to tell computers and humans apart through a challenge-response test used to ensure that the response is not machine generated. CAPTCHA comes in many forms; some are more popular than the others:
1. Text based CAPTCHAs in which the user sees an image displaying letters or numbers and is asked to type what he sees
2. Image recognition CAPTCHAs which display some images and ask questions about their content. Microsoft Assira is an example
3. 3D CAPTCHAs which display complex computer generated 3D graphics scenes and ask about the 3D scene's details and content
Image recoginition and 3D recognition try to impose more difficulty on computer programs that try to break CAPTCHAs.
reCAPTCHA is one of the CAPTCHA efforts. It tries to solve another problem in addition to fighting spam; it tries to improve the process of digitizing books by sending words that cannot be read by computers to the Web in the form of CAPTCHAs for humans to decipher. The question that popped immediately in my mind was how does reCAPTCHA verify the answers if it's using images of words that the computer couldn't really figure out what they were while scanning them. The answer is simple: it displays two words at a time, one word can be easily verified and as for the other word, your solution is taken to be a suggestion for that word. That word is used many times in different CAPTCHAs and eventually many people will suggest the same thing.
Currently, reCAPTCHA is recommended as the official CAPTCHA implementation by the original CAPTCHA creators. This way reCAPTCHA not only helps you in fighting spam, but it also gets you to participate into a good cause like digitizing the world's books.
Using reCAPTCHA in your Rails application is made easy thanks to the reCAPTHCA plugin. This plugin gives you 2 main methods that you can use in your application:
1.recaptcha_tags, which should be used in the view in your form.
2.verify_recaptcha, which should be used in the controllers to verify the user's answer
You should register at reCAPTCHA to get your public and private keys which are required by the plugin. The plugin requires that you define them as Environment variables.
recaptcha_tags accepts an options hash which can define the public key with :public_key, so that it doesn't look in your environment variables.
verify_recaptcha - which uses the private key - initially didn't provide a way for you to pass the private_key.
I've forked the plugin here and modified verify_recaptcha so that it now accepts an options hash - like recaptcha_tags - which allows you to define :private_key, which will be used instead of looking into the environment variables. I sent a pull request to the guys over at http://github.com/ambethia/recaptcha to include my changes. Peter Abrahamsen replied and after a couple of messages we modified the plugin so that we no longer need to set the public and private key in any environment variables. We also added a toggle to enable/disable the plugin. We can use the plugin as follows now:
Ambethia::ReCaptcha.enabled = true Ambethia::ReCaptcha.public_key = '0123456789ABCDEF' Ambethia::ReCaptcha.private_key = '0123456789ABCDEF'
If the toggle is set to false, the recaptcha_tags will return nothing and the verify_recaptcha will always return true meaning that the reCAPTCHA code does nothing, which is what we want in case of disabling it.
Fight spam, help in digitizing books, use reCAPTCHA !
Written By:
Comments
Post a Comment
eSpace podcast Prodcast
Archive
- September 2011
- April 2011
- March 2011
- December 2010
- November 2010
- September 2010
- August 2010
- July 2010
- June 2010
- April 2010
- March 2010
- November 2009
- October 2009
- September 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- September 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- January 2008
- April 2007
- March 2007
Latest Comments
- SpectraMind Commented on Egypt Wins UK's National Outsourcing Association Award
- Rofaida Awad Commented on Go Egypt Go!
- Different Mike Commented on Only idiots change their iPhone root password!
- Mike Commented on Only idiots change their iPhone root password!
- smile Commented on Only idiots change their iPhone root password!

