1Lemonldap::NG::Portal::UMsaeirn:C:oSnetcroinbduLFteaemcdotnoPlred(ra3lp):D:oNcGu:m:ePnotrattailo:n:Main::SecondFactor(3)
2
3
4
6 Lemonldap::NG::Portal::Main::SecondFactor - Base class for
7 Lemonldap::NG::Portal second factor plugins.
8
10 package Lemonldap::NG::Portal::2F::MySecondFactor;
11 use Mouse;
12 # Import used constants
13 use Lemonldap::NG::Portal::Main::Constants qw(
14 PE_OK
15 PE_BADCREDENTIALS
16 PE_SENDRESPONSE
17 );
18 extends 'Lemonldap::NG::Portal::Main::SecondFactor';
19
20 # INITIALIZATION
21
22 # Prefix that will be used in parameter names. The form used to enter the
23 # second factor must post its result to "/my2fcheck" (if "my" is the prefix).
24 has prefix => ( is => 'ro', default => 'my' );
25 # Optional logo
26 has logo => ( is => 'rw', default => 'mylogo.png' );
27
28 # Required init method
29 sub init {
30 my ($self) = @_;
31 # Insert here initialization process
32 #
33 # If self registration is enabled and "activation" is set to "enabled",
34 # replace the rule to detect if user has registered a device key.
35 # The rule must be like this :
36 # By example :
37 $self->conf->{u2fActivation} = '$_2fDevices =~ /"type":\s*"U2F"/s'
38 # Optionally, the rule can be : '$_2fDevices and $_2fDevices =~ /"type":\s*"U2F"/s'
39 # to avoid warning due to undef variable
40 #
41 # Required call:
42 return $self->SUPER::init();
43 }
44
45 # RUNNING METHODS
46
47 # Required 2nd factor send method
48 sub run {
49 my ( $self, $req, $token ) = @_;
50 # $token must be inserted in a hidden input in your form with the name
51 # "token"
52 ...
53 # A LLNG constant must be returned. Example:
54 $req->response($my_psgi_response)
55 return PE_SENDRESPONSE;
56 }
57 # Required 2nd factor verify method
58 sub verify {
59 my ( $self, $req, $session ) = @_;
60 # Use $req->param('field') to get POST responses
61 ...
62 if ($result eq $goodResult) {
63 return PE_OK;
64 }
65 else {
66 return PE_BADCREDENTIALS
67 }
68 }
69
70 Enable your plugin in lemonldap-ng.ini, section [portal]:
71
72 <prefix>2fActivation (required): 1, 0 or a rule
73 <prefix>2fAuthnLevel (optional): change authentication level for users
74 authenticated by this plugin
75
76 Example:
77
78 [portal]
79 customPlugins = Lemonldap::NG::Portal::2F::MyPlugin
80 my2fActivation = 1
81 my2fAuthnLevel = 4
82
84 Lemonldap::NG::Portal::Main::SecondFactor provides a simple framework
85 to build Lemonldap::NG second authentication factor plugin.
86
87 See Lemonldap::NG::Portal::Plugins::2F::* packages for examples.
88
90 <http://lemonldap-ng.org>
91
92 OTHER POD FILES
93 Writing an authentication module: Lemonldap::NG::Portal::Auth
94 Writing a UserDB module: Lemonldap::NG::Portal::UserDB
95 Writing a second factor module:
96 Lemonldap::NG::Portal::Main::SecondFactor
97 Writing an issuer module: Lemonldap::NG::Portal::Main::Issuer
98 Writing another plugin: Lemonldap::NG::Portal::Main::Plugin
99 Request object: Lemonldap::NG::Portal::Main::Request
100 Adding parameters in the manager: Lemonldap::NG::Manager::Build
101
103 LemonLDAP::NG team <http://lemonldap-ng.org/team>
104
106 Use OW2 system to report bug or ask for features:
107 <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
108
110 Lemonldap::NG is available at <https://lemonldap-ng.org/download>
111
113 See COPYING file for details.
114
115 This library is free software; you can redistribute it and/or modify it
116 under the terms of the GNU General Public License as published by the
117 Free Software Foundation; either version 2, or (at your option) any
118 later version.
119
120 This program is distributed in the hope that it will be useful, but
121 WITHOUT ANY WARRANTY; without even the implied warranty of
122 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
123 General Public License for more details.
124
125 You should have received a copy of the GNU General Public License along
126 with this program. If not, see <http://www.gnu.org/licenses/>.
127
128
129
130perl v5.36.1 2L0e2m3o-n1l1d-a1p4::NG::Portal::Main::SecondFactor(3)