.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CGI::Application::Plugin::CAPTCHA 3pm" .TH CGI::Application::Plugin::CAPTCHA 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CGI::Application::Plugin::CAPTCHA \- Easily create, use, and verify CAPTCHAs in CGI::Application\-based web applications. .SH "VERSION" .IX Header "VERSION" Version 0.04 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # In your CGI::Application\-based web application module. . . \& use CGI::Application::Plugin::CAPTCHA; \& \& sub setup \& { \& my $self = shift; \& \& $self\->run_modes([ qw/ \& create \& # Your other run modes go here \& /]); \& \& $self\->captcha_config( \& IMAGE_OPTIONS => { \& width => 150, \& height => 40, \& lines => 10, \& font => "/Library/Fonts/Arial", \& ptsize => 18, \& bgcolor => "#FFFF00", \& }, \& CREATE_OPTIONS => [ \*(Aqttf\*(Aq, \*(Aqrect\*(Aq ], \& PARTICLE_OPTIONS => [ 300 ], \& ); \& } \& \& # Create a run mode that calls the CAPTCHA creation method... \& sub create \& { \& my $self = shift; \& return $self\->captcha_create; \& } \& \& # In a template far, far away. . . \& (to generate a CAPTCHA image) \& \& # Back in your application, to verify the CAPTCHA... \& sub some_other_runmode \& { \& my $self = shift; \& my $request = $self\->query; \& \& return unless $self\->captcha_verify($request\->cookie("hash"), $request\->param("verify")); \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`CGI::Application::Plugin::CAPTCHA\*(C'\fR allows programmers to easily add and verify CAPTCHAs in their CGI::Application\-derived web applications. .PP A \s-1CAPTCHA\s0 (or Completely Automated Public Turing Test to Tell Computers and Humans Apart) is an image with a random string of characters. A user must successfully enter the random string in order to submit a form. This is a simple (yet annoying) procedure for humans to complete, but one that is significantly more difficult for a form-stuffing script to complete without having to integrate some sort of \s-1OCR.\s0 .PP CAPTCHAs are not a perfect solution. Any skilled, diligent cracker will eventually be able to bypass a \s-1CAPTCHA,\s0 but it should be able to shut down your average script-kiddie. .PP \&\f(CW\*(C`CGI::Application::Plugin::CAPTCHA\*(C'\fR is a wrapper for GD::SecurityImage. It makes it more convenient to access GD::SecurityImage functionality, and gives a more CGI::Application\-like way of doing it. .PP When a \s-1CAPTCHA\s0 is created with this module, raw image data is transmitted from your web application to the client browser. A cookie containing a checksum is also transmitted with the image. When the client submits their form for processing (along with their verification of the random string), \&\f(CW\*(C`captcha_verify()\*(C'\fR generates a checksum of the verification string the user entered. If the newly generated checksum matches the checksum found in the cookie, we trust that the \s-1CAPTCHA\s0 has been successfully entered, and we allow the user to continue processing their form. .PP The checksum is generated by taking the string in question, and joining it with a \s-1SECRET.\s0 We then generate an \s-1SHA1\s0 hex digest of the resulting string. The end user will not be able to generate their own checksums to bypass the \s-1CAPTCHA\s0 check, because they do not know the value of our \s-1SECRET.\s0 This means it is important to choose a good value for your \s-1SECRET.\s0 .PP An easy way to generate a relatively good secret is to run the following perl snippet: .PP .Vb 1 \& perl \-MDigest::SHA=sha1_base64 \-le \*(Aqprint sha1_base64($$,time(),rand(9999))\*(Aq .Ve .PP The author recognizes that the transmission of a cookie with the \s-1CAPTCHA\s0 image may not be a popular decision, and welcomes any patches from those who can provide an equally easy-to-implement solution. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "\fBcaptcha_config()\fP" .IX Subsection "captcha_config()" This method is used to customize how new \s-1CAPTCHA\s0 images will be created. Values specified here are passed along to the appropriate functions in GD::SecurityImage when a new \s-1CAPTCHA\s0 is created. .PP It is recommended that you call \f(CW\*(C`captcha_config()\*(C'\fR in the \f(CW\*(C`cgiapp_init()\*(C'\fR method of your CGI::Application base class, and in the \f(CW\*(C`setup()\*(C'\fR method of any derived applications. .PP The following parameters are currently accepted: .PP \fI\s-1IMAGE_OPTIONS\s0\fR .IX Subsection "IMAGE_OPTIONS" .PP This specifies what options will be passed to the constructor of GD::SecurityImage. Please see the documentation for GD::SecurityImage for more information. .PP \fI\s-1CREATE_OPTIONS\s0\fR .IX Subsection "CREATE_OPTIONS" .PP This specifies what options will be passed to the \f(CW\*(C`create()\*(C'\fR method of GD::SecurityImage. Please see the documentation for GD::SecurityImage for more information. .PP \fI\s-1PARTICLE_OPTIONS\s0\fR .IX Subsection "PARTICLE_OPTIONS" .PP This specifies what options will be passed to the \f(CW\*(C`particle()\*(C'\fR method of GD::SecurityImage. Please see the documentation for GD::SecurityImage for more information. .PP \fI\s-1SECRET\s0\fR .IX Subsection "SECRET" .PP This specifies the secret that will be used when generating the checksum hash. .SS "\fBcaptcha_create()\fP" .IX Subsection "captcha_create()" Creates the \s-1CAPTCHA\s0 image, and return a cookie with the encrypted hash of the random string. Takes no arguments. .PP The cookie created in this method is named \f(CW\*(C`hash\*(C'\fR, and contains only the encrypted hash. Future versions of this module will allow you to specify cookie options in greater detail. .SS "\fBcaptcha_verify()\fP" .IX Subsection "captcha_verify()" Verifies that the value entered by the user matches what was in the \s-1CAPTCHA\s0 image. Argument 1 is the encrypted hash from the cookie sent by \&\f(CW\*(C`captcha_create()\*(C'\fR, and argument 2 is the value the user entered to verify the \s-1CAPTCHA\s0 image. Returns true if the \s-1CAPTCHA\s0 was successfully verified, else returns false. .SH "AUTHOR" .IX Header "AUTHOR" Jason A. Crome, \f(CW\*(C`\*(C'\fR .SH "TODO" .IX Header "TODO" .IP "\(bu" 4 Allow \f(CW\*(C`captcha_config()\*(C'\fR to take cookie configuration arguments. .IP "\(bu" 4 Allow the plugin to actually create a run mode in your CGI::Application\-based webapp without the developer having to manually create one. .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-cgi\-application\-plugin\-captcha@rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "CONTRIBUTING" .IX Header "CONTRIBUTING" Patches, questions, and feedback are welcome. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" A big thanks to Cees Hek for providing a great module for me to borrow code from (CGI::Application::Plugin::Session), to Michael Peters and Tony Fraser for all of their valuable input, and to the rest who contributed ideas and criticisms on the CGI::Application mailing list. .PP Additional thanks to chorny and Cees for the various bug fixes and patches they have submitted. .SH "SEE ALSO" .IX Header "SEE ALSO" CGI::Application GD::SecurityImage Wikipedia entry for \s-1CAPTCHA\s0 \- .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2005\-2011 Jason A. Crome, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.