1Lemonldap::NG::Portal::UCsaeprtcChoan(t3r)ibuted Perl DoLceummoennltdaatpi:o:nNG::Portal::Captcha(3)
2
3
4

NAME

6       Lemonldap:NG::Portal::Captcha - Writing CAPTCHA modules for
7       LemonLDAP::NG.
8

SYNOPSIS

10         package Lemonldap::NG::Portal::Captcha::My;
11
12         use strict;
13         use Mouse;
14         # Add constants used by this module
15
16         our $VERSION = '0.1';
17
18         extends 'Lemonldap::NG::Portal::Main::Plugin';
19
20         sub init {
21             my $self = shift;
22             return 1;
23         }
24
25         sub init_captcha {
26           my ( $self, $req ) = @_;
27
28           # Read option from the manager configuration
29           my $option = $self->conf->{captchaOptions}->{option1};
30
31           # This can be used to inject custom JS code at the beginning
32           # of the page
33           my $script = <your html code>;
34           $req->data->{customScript} .= $script;
35
36           # This will add your custom HTML code to the protected form
37           my $html = <your html code>;
38           $req->captchaHtml($html);
39         }
40
41         sub check_captcha {
42           my ( $self, $req ) = @_;
43
44           my $captcha_input = $req->param('some_post_param');
45           my $is_captcha_valid = <your code here>;
46
47           if($is_captcha_valid) {
48               return 1;
49           } else {
50               return 0;
51           }
52         }
53
54         1;
55

DESCRIPTION

57       Captcha modules only need to implement two methods: one for
58       initializing the challenge, before the form is displayed, and the other
59       to verify that the submitted response is correct.
60

METHODS

62   Accessors and methods provided by Lemonldap::NG::Portal::Main::Plugin
63       p: portal object
64       conf: configuration hash (as reference)
65       logger alias for p->logger accessor
66       userLogger alias for p->userLogger accessor
67       error: alias for p->error method
68
69   "Routes" management
70       Like each module that inherits from Lemonldap::NG::Portal::Plugin, you
71       can define dedicated routes in a Captcha plugin.
72
73       addAuthRoute: wrapper to Lemonldap::NG::Handler::PSGI::Try
74       addAuthRoute() method
75       addUnauthRoute: wrapper to Lemonldap::NG::Handler::PSGI::Try
76       addUnauthRoute() method
77
78   Methods that must be provided by a Captcha module
79       init_captcha($req)
80
81       This method is called when the protected form is built by
82       LemonLDAP::NG.  Your responsibility is to do any preparatory step, and
83       provide LemonLDAP::NG with the HTML code that it has to display in the
84       form to enable the Captcha.
85
86       This is done by setting "$req->captchaHtml"
87
88       check_captcha($req)
89
90       This method is called after the user submitted the protected form. Your
91       responibility is to check the user's response (usually provided as a
92       POST field), and return 0 if the response is incorrect, 1 if the
93       response is correct.
94

LOGGING

96       Logging is provided by "$self->logger" and "$self->userLogger". See
97       Lemonldap::NG::Portal::Main::Plugin for a detailed description of
98       logging levels.
99

AUTHORS

101       LemonLDAP::NG team <http://lemonldap-ng.org/team>
102

BUG REPORT

104       Use OW2 system to report bug or ask for features:
105       <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
106

DOWNLOAD

108       Lemonldap::NG is available at <https://lemonldap-ng.org/download>
109
111       See COPYING file for details.
112
113       This library is free software; you can redistribute it and/or modify it
114       under the terms of the GNU General Public License as published by the
115       Free Software Foundation; either version 2, or (at your option) any
116       later version.
117
118       This program is distributed in the hope that it will be useful, but
119       WITHOUT ANY WARRANTY; without even the implied warranty of
120       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
121       General Public License for more details.
122
123       You should have received a copy of the GNU General Public License along
124       with this program.  If not, see <http://www.gnu.org/licenses/>.
125
126
127
128perl v5.38.0                      2023-11-14 Lemonldap::NG::Portal::Captcha(3)
Impressum