Lemonld...::UserDB(3)

πŸ’– Lemonld...::UserDB(3) πŸ’–

okay bestie, welcome to the Lemonld...::UserDB(3) page β€” it lives in the User Contributed Perl Documentation section of the manual, and it's literally your whole guide to writing user storage modules. grab a strawberry πŸ“ and let's go.


✨ NAME ✨

Lemonldap:NG::Portal::UserDB β€” writing user storage modules for LemonLDAP::NG. that's the whole vibe, fr fr.


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the skeleton, copy it exactly bestie:

package Lemonldap::NG::Portal::UserDB::My;

use strict;
use Mouse;
# Add constants used by this module
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK);

our $VERSION = '0.1';

extends 'Lemonldap::NG::Portal::Main::UserDB';

sub init {
    ...
}

sub getUser {
    my ( $self, $req, %args ) = @_;
    ...
}

sub setSessionInfo {
    my ( $self, $req ) = @_;
    ...
}

sub setGroups {
    my ( $self, $req ) = @_;
    ...
}

🌸 DESCRIPTION 🌸

so, UserDB modules are the little icons that go searching for a user in a user database. πŸ‘‘ they're independent objects that get instantiated by the Lemonldap::NG portal, and they must provide the methods listed down below. no skipping, no cap.


πŸ’… METHODS πŸ’…

πŸŽ€ Accessors and methods provided by Lemonldap::NG::Common::Module

these come free with the module, like a gift with purchase:

  • p β€” the portal object
  • conf β€” configuration hash (as reference)
  • logger β€” alias for the p->logger accessor
  • userLogger β€” alias for the p->userLogger accessor
  • error β€” alias for the p->error method

✨ "Routes" management

like any module that inherits from Lemonldap::NG::Portal::Plugin, Lemonldap::NG::Portal::Main::Auth provides URI path functions:

  • addAuthRoute β€” wrapper to Lemonldap::NG::Handler::PSGI::Try addAuthRoute() method
  • addUnauthRoute β€” wrapper to Lemonldap::NG::Handler::PSGI::Try addUnauthRoute() method

example, because seeing it > reading about it:

sub init {
    ...
    $self->addAuthRoute( saml => { proxy => "proxySub" }, [ 'GET', 'POST' ] );
    ...
}
sub proxySub {
    my ( $self, $req ) = @_;
    ...
    # This sub must return a PSGI response. Example
    return [ 302, [ Location => 'http://x.y/' ], [] ];
}

which means requests to http://auth.../saml/proxy get handed straight to the proxySub() method. slay. 🫢


πŸ’œ Methods that must be provided by a UserDB module

init()

this one runs after object creation (so, after each configuration reload). it must return a true value if the authentication module is ready, and false if it's not. that's it, that's the rule. πŸ™ˆ

🧚 Methods called at each request

all of these methods must return a Lemonldap::NG::Portal::Main::Constants value. they get called with one argument: a Lemonldap::NG::Portal::Main::Request object. one (1) argument. iconic.

note: if you wanna change process() next steps, you just have to change the $req->steps array. πŸ’…

getUser($req,%args)

the first method called to search for a user in the database. if $args{useMail} is set, then $req->{user} contains a mail address. πŸ“§

setSessionInfo($req)

this one is called after the authentication process, and it must populate $req->sessionInfo. no pressure bestie.

setGroups($req)

this populates $req->{sessionInfo}->{groups} if the backend is able to provide groups (like LDAP does). otherwise? it just returns PE_OK. simple as that.


🌈 LOGGING 🌈

logging is provided by $self->logger and $self->userLogger. the following rules must be applied, so listen up:

  • logger->debug β€” technical debugging messages
  • logger->info β€” simple technical information
  • logger->notice β€” technical information that could interest administrators
  • logger->warn β€” technical warning
  • logger->error β€” error that must be reported to administrator
  • userLogger->info β€” simple information about user's action
  • userLogger->notice β€” information that may be registered (auth success,...)
  • userLogger->warn β€” bad action of a user (auth failure). Auth/Combination transform it to "info" when another authentication scheme is available
  • userLogger->error β€” bad action of a user that must be reported, (even if another backend is available with Combination)

πŸ‘‘ AUTHORS πŸ‘‘

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


πŸ’€ BUG REPORT πŸ’€

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


⭐ DOWNLOAD ⭐

Lemonldap::NG is available at <https://lemonldap-ng.org/download>


see COPYING file for details.

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/>.


okay that's the whole page bestie, you ate it up πŸ’– this was written for perl v5.42.3 and dated 2026-09-24 β€” go write some user storage modules, main character energy only βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from