.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 .\" ======================================================================== .\" .IX Title "Lemonldap::NG::Portal::Captcha 3pm" .TH Lemonldap::NG::Portal::Captcha 3pm 2024-04-30 "perl v5.38.2" "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 Lemonldap:NG::Portal::Captcha \- Writing CAPTCHA modules for LemonLDAP::NG. .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& package Lemonldap::NG::Portal::Captcha::My; \& \& use strict; \& use Mouse; \& # Add constants used by this module \& \& our $VERSION = \*(Aq0.1\*(Aq; \& \& extends \*(AqLemonldap::NG::Portal::Main::Plugin\*(Aq; \& \& sub init { \& my $self = shift; \& return 1; \& } \& \& sub init_captcha { \& my ( $self, $req ) = @_; \& \& # Read option from the manager configuration \& my $option = $self\->conf\->{captchaOptions}\->{option1}; \& \& # This can be used to inject custom JS code at the beginning \& # of the page \& my $script = ; \& $req\->data\->{customScript} .= $script; \& \& # This will add your custom HTML code to the protected form \& my $html = ; \& $req\->captchaHtml($html); \& } \& \& sub check_captcha { \& my ( $self, $req ) = @_; \& \& my $captcha_input = $req\->param(\*(Aqsome_post_param\*(Aq); \& my $is_captcha_valid = ; \& \& if($is_captcha_valid) { \& return 1; \& } else { \& return 0; \& } \& } \& \& 1; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Captcha modules only need to implement two methods: one for initializing the challenge, before the form is displayed, and the other to verify that the submitted response is correct. .SH METHODS .IX Header "METHODS" .SS "Accessors and methods provided by Lemonldap::NG::Portal::Main::Plugin" .IX Subsection "Accessors and methods provided by Lemonldap::NG::Portal::Main::Plugin" .IP "p: portal object" 4 .IX Item "p: portal object" .PD 0 .IP "conf: configuration hash (as reference)" 4 .IX Item "conf: configuration hash (as reference)" .IP "logger alias for p\->logger accessor" 4 .IX Item "logger alias for p->logger accessor" .IP "userLogger alias for p\->userLogger accessor" 4 .IX Item "userLogger alias for p->userLogger accessor" .IP "error: alias for p\->error method" 4 .IX Item "error: alias for p->error method" .PD .SS """Routes"" management" .IX Subsection """Routes"" management" Like each module that inherits from Lemonldap::NG::Portal::Plugin, you can define dedicated routes in a Captcha plugin. .IP "addAuthRoute: wrapper to Lemonldap::NG::Handler::PSGI::Try \fBaddAuthRoute()\fR method" 4 .IX Item "addAuthRoute: wrapper to Lemonldap::NG::Handler::PSGI::Try addAuthRoute() method" .PD 0 .IP "addUnauthRoute: wrapper to Lemonldap::NG::Handler::PSGI::Try \fBaddUnauthRoute()\fR method" 4 .IX Item "addUnauthRoute: wrapper to Lemonldap::NG::Handler::PSGI::Try addUnauthRoute() method" .PD .SS "Methods that must be provided by a Captcha module" .IX Subsection "Methods that must be provided by a Captcha module" \fIinit_captcha($req)\fR .IX Subsection "init_captcha($req)" .PP This method is called when the protected form is built by LemonLDAP::NG. Your responsibility is to do any preparatory step, and provide LemonLDAP::NG with the HTML code that it has to display in the form to enable the Captcha. .PP This is done by setting \f(CW\*(C`$req\->captchaHtml\*(C'\fR .PP \fIcheck_captcha($req)\fR .IX Subsection "check_captcha($req)" .PP This method is called after the user submitted the protected form. Your responibility is to check the user's response (usually provided as a POST field), and return 0 if the response is incorrect, 1 if the response is correct. .SH LOGGING .IX Header "LOGGING" Logging is provided by \f(CW\*(C`$self\->logger\*(C'\fR and \f(CW\*(C`$self\->userLogger\*(C'\fR. See Lemonldap::NG::Portal::Main::Plugin for a detailed description of logging levels. .SH AUTHORS .IX Header "AUTHORS" .IP "LemonLDAP::NG team " 4 .IX Item "LemonLDAP::NG team " .SH "BUG REPORT" .IX Header "BUG REPORT" Use OW2 system to report bug or ask for features: .SH DOWNLOAD .IX Header "DOWNLOAD" Lemonldap::NG is available at .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" See COPYING file for details. .PP This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. .PP This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. .PP You should have received a copy of the GNU General Public License along with this program. If not, see .