Lemonld...Captcha(3)
π Lemonld...Captcha(3) β aka Lemonldap::NG::Portal::Captcha π
okay bestie, pull up a chair, because we're writing CAPTCHA modules for LemonLDAP::NG and honestly? it's giving main character energy. This is from the User Contributed Perl Documentation collection, and it's your whole guide. Let's go. π¦
β¨ NAME β¨
Lemonldap::NG::Portal::Captcha β the vibe here is writing CAPTCHA modules for LemonLDAP::NG. That's it. That's the job. π
β¨ SYNOPSIS β¨
Here's the whole blueprint, bestie β copy the shape, fill in the blanks:
package Lemonldap::NG::Portal::Captcha::My;
use strict;
use Mouse;
# Add constants used by this module
our $VERSION = '0.1';
extends 'Lemonldap::NG::Portal::Main::Plugin';
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 = <your html code>;
$req->data->{customScript} .= $script;
# This will add your custom HTML code to the protected form
my $html = <your html code>;
$req->captchaHtml($html);
}
sub check_captcha {
my ( $self, $req ) = @_;
my $captcha_input = $req->param('some_post_param');
my $is_captcha_valid = <your code here>;
if($is_captcha_valid) {
return 1;
} else {
return 0;
}
}
1;
β¨ DESCRIPTION β¨
Okay so here's the tea: a Captcha module only needs two methods, that's the whole personality. One of them sets up the challenge before the form gets displayed, and the other one verifies that whatever the user sent back is actually correct. Two methods. Iconic. Periodt. π
β¨ METHODS β¨
πΈ Accessors and methods provided by Lemonldap::NG::Portal::Main::Plugin πΈ
Freebies you inherit, no cap:
pβ the portal object π«Άconfβ the configuration hash (as a reference, bestie, don't forget that part)loggerβ alias for thep->loggeraccessoruserLoggerβ alias for thep->userLoggeraccessorerrorβ alias for thep->errormethod
π "Routes" management π
Just like every module that inherits from Lemonldap::NG::Portal::Plugin, you can define dedicated routes in a Captcha plugin. Yes, you. Custom routes. Slay.
addAuthRouteβ wrapper to theLemonldap::NG::Handler::PSGI::Try addAuthRoute()methodaddUnauthRouteβ wrapper to theLemonldap::NG::Handler::PSGI::Try addUnauthRoute()method
π¦ Methods that must be provided by a Captcha module π¦
These two are non-negotiable, they're the moment, they're the whole plot:
init_captcha($req)
This one gets called when the protected form is built by LemonLDAP::NG. Your responsibility? Do any preparatory step you need, and then hand LemonLDAP::NG the HTML code it has to display in the form so the Captcha actually shows up. β¨
And how do you hand it over? By setting $req->captchaHtml β that's the move. π
check_captcha($req)
This one gets called after the user submitted the protected form. Your responsibility is to check the user's response (usually it comes in as a POST field) and then:
- return
0if the response is incorrect π - return
1if the response is correct π₯
That's it. Binary. Clean. No in-between.
β¨ LOGGING β¨
Logging is provided by $self->logger and $self->userLogger. If you want the full detailed description of logging levels, go read up on Lemonldap::NG::Portal::Main::Plugin β they've got the whole breakdown over there. π
β¨ AUTHORS β¨
LemonLDAP::NG team <http://lemonldap-ng.org/team> π
β¨ BUG REPORT β¨
Found a bug? Need a feature? Bestie, use the OW2 system β that's the whole protocol: <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
β¨ DOWNLOAD β¨
Lemonldap::NG is available at <https://lemonldap-ng.org/download> β go get it, it's right there. π«Ά
β¨ COPYRIGHT AND LICENSE β¨
See the COPYING file for details, bestie.
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.
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.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
And that's the whole page, bestie β you ate. πβ¨ Sign-off time: this was generated by perl v5.42.3, dated 2026-09-24, and the page title is Lemonld...Captcha(3). No cap, go write that Captcha module. ππ¦πΈ
π¦ where this page comes from
- fedora 43: lemonldap-ng-portal 2.23.4-1.fc43 Β· GPL-2.0-or-later AND MIT AND GPL-3.0-or-later AND OFL-1.1-RFN
- fedora 44: lemonldap-ng-portal 2.23.4-1.fc44 Β· GPL-2.0-or-later AND MIT AND GPL-3.0-or-later AND OFL-1.1-RFN
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms