Posts tagged "recaptcha"

rack-recaptcha - a different approach to recaptcha integration

Rack Middleware

A while back, I wanted to dabble into rack middleware and the best way was to create one myself. Without getting too indepth, Rack middlewares act as the cascading stylesheets for applications. You stack middlewares on top of your rack compatible application. As requests come in, each middleware runs its process and passes it to the next layer until it reaches the main application.

RECAPTCHA

Recaptcha is a CAPTCHA verification service that operates by pulling scanned text for users to verify a human operator. In most use cases, CAPTCHA verification is used to check comments, posts, or even account creation.

rack-recaptcha

There are libraries out that they handle RECAPTCHA verification. However, they are limited only to Rails apps. At the time of creation of rack-recaptcha, I needed a library that I could use with other rack compatible frameworks such as Sinatra and Padrino. Rack seemed like a good solution to ensure agnosticism among rack compatible apps.

Adding a RECAPTCHA solution is two parts:

  • Verification - Send the RECAPTCHA request and verify the results
  • Client Helpers - RECAPTCHA form generation

With middlewares, the verification request can be processed in the middleware and pass its results back to the application. If the request coming in doesn’t require RECAPTCHA, the request is immediately passed down the stack.

This keeps the library lean. No extra code for integration with Rails, Merb, Sinatra, Padrino or whatever framework you use.

If you want to check out the library, its on github or install it with:

$ gem install rack-recaptcha

That’s all for now. thanks for reading!

My postings on technology, philosophy, and this journey called life.

view archive