Authen::PluggableCaptcha

Authen::PluggableCaptcha is a pluggable Captcha framework for Perl.
Download

Authen::PluggableCaptcha Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jonathan Vanasco
  • Publisher web site:
  • http://search.cpan.org/~jvanasco/Authen-PluggableCaptcha-0.05/lib/Authen/PluggableCaptcha/Tutorial.pm

Authen::PluggableCaptcha Tags


Authen::PluggableCaptcha Description

Authen::PluggableCaptcha is a pluggable Captcha framework for Perl. Authen::PluggableCaptcha is a pluggable Captcha framework for Perl.SYNOPSISIMPORTANT-- the .03 release is incompatible with earlier versions. Most notably: all external hooks for hash mangling have been replaced with object methods ( ie: $obj->{'__Challenge'} is now $obj->challenge ) and keyword arguments expecting a class name have the word '_class' as a suffix.Authen::PluggableCaptcha is a framework for creating Captchas , based on the idea of creating Captchas with a plugin architecture.The power of this module is that it creates Captchas in the sense that a programmer writes Perl modules-- not just in the sense that a programmer calls a Captcha library for display.The essence of a Captcha has been broken down into three components: KeyManager , Challenge and Render -- all of which programmers now have full control over. Mix and match existing classes or create your own. Authen::PluggableCaptcha helps you make your own captcha tests -- and it helps you do it fast.The KeyManager component handles creating & validatiing keys that are later used to uniquely identify a CAPTCHA. By default the KeyManager uses a time-based key system, but it can be trivially extended to integrate with a database and make single-use keys.The Challenge component maps a key to a set of instructions, a user prompt , and a correct response.The render component is used to display the challenge - be it text, image or sound. use Authen::PluggableCaptcha; use Authen::PluggableCaptcha::Challenge::TypeString; use Authen::PluggableCaptcha::Render::Image::Imager; # create a new captcha for your form my $captcha= Authen::PluggableCaptcha->new( type=> "new", seed=> $session->user->seed , site_secret=> $MyApp::Config::site_secret ); my $captcha_publickey= $captcha->get_publickey(); # image captcha? create an html link to your captcha script with the public key my $html= qq||; # image captcha? render it my $existing_publickey= 'a33d8ce53691848ee1096061dfdd4639_1149624525'; my $existing_publickey = $apr->param('captcha_publickey'); my $captcha= Authen::PluggableCaptcha->new( type=> 'existing' , publickey=> $existing_publickey , seed=> $session->user->seed , site_secret=> $MyApp::Config::site_secret ); # save it as a file my $as_string= $captcha->render( challenge_class=> 'Authen::PluggableCaptcha::Challenge::TypeString', render_class=>'Authen::PluggableCaptcha::Render::Image::Imager' , format=>'jpeg' ); open(WRITE, ">test.jpg"); print WRITE $as_string; close(WRITE); # or serve it yourself $r->add_header('Content Type: image/jpeg'); $r->print( $as_string ); # wait, what if we want to validate the captcha first? my $captcha= Authen::PluggableCaptcha->new( type=> 'existing' , publickey=> $apr->param('captcha_publickey'), seed=> $session->user->seed , site_secret= $MyApp::Config::site_secret ); if ( !$captcha->validate_response( user_response=> $apr->param('captcha_response') ) ) { my $reason= $captcha->get_error('validate_response'); die "could not validate captcha because: ${reason}."; };in the above example, $captcha->new just configures the captcha. $captcha->render actually renders the image. if the captcha is expired (too old by the default configuration) , the default expired captcha routine from the plugin will take place better yet, handle all the timely and ip/request validation in the application logic. the timeliness just makes someone answer a captcha 1x every 5minutes, but doesn't prevent re/mis userender accepts a 'render_class' argument that will internally dispatch the routines to a new instance of that class.using this method, multiple renderings and formats can be created using a single key and challenge. Requirements: · Perl


Authen::PluggableCaptcha Related Software