1Lemonldap::NG::Handler:U:sPeSrGIC:o:nRtoruitbeurt(e3d)PLeermlonDlodcaupm:e:nNtGa:t:iHoanndler::PSGI::Router(3)
2
3
4

NAME

6       Lemonldap::NG::Handler::PSGI::Router - Base library for protected REST
7       APIs of Lemonldap::NG.
8

SYNOPSIS

10         package My::PSGI;
11
12         use base Lemonldap::NG::Handler::PSGI::Router;
13
14         sub init {
15           my ($self,$args) = @_;
16           $self->protection('manager');
17           # See Lemonldap::NG::Common::PSGI::Router for more
18
19           # Declare REST routes (could be HTML templates or methods)
20           $self->addRoute ( 'index.html', undef, ['GET'] )
21                ->addRoute ( books => { ':book' => 'booksMethod' }, ['GET', 'POST'] );
22
23           # Default route (ie: PATH_INFO == '/')
24           $self->defaultRoute('index.html');
25
26           # Return a boolean. If false, then error message has to be stored in
27           # $self->error
28           return 1;
29         }
30
31         sub booksMethod {
32           my ( $self, $req, @otherPathInfo ) = @_;
33
34           # Will be called only if authorized
35           my $userId = $self->userId;
36           my $book = $req->params('book');
37           my $method = $req->method;
38           ...
39           $self->sendJSONresponse(...);
40         }
41
42       This package could then be called as a CGI, using FastCGI,...
43
44         #!/usr/bin/env perl
45
46         use My::PSGI;
47         use Plack::Handler::FCGI; # or Plack::Handler::CGI
48
49         Plack::Handler::FCGI->new->run( My::PSGI->run() );
50

DESCRIPTION

52       This package provides base class for Lemonldap::NG protected REST API.
53

METHODS

55       See Lemonldap::NG::Common::PSGI for logging methods, content
56       sending,...
57
58   Accessors
59       See Lemonldap::NG::Common::PSGI::Router for inherited accessors.
60
61       protection
62
63       Level of protection. It can be one of:
64
65       'none': no protection
66       'authenticate': all authenticated users are granted
67       'manager': access is granted following Lemonldap::NG rules
68
69   Running methods
70       user
71
72       Returns user session data. If empty (no protection), returns:
73
74         { _whatToTrace => 'anonymous' }
75
76       But if page is protected by server (Auth-Basic,...), it will return:
77
78         { _whatToTrace => $REMOTE_USER }
79
80       UserId
81
82       Returns user()->{'_whatToTrace'}.
83
84       group
85
86       Returns a list of groups to which user belongs.
87

SEE ALSO

89       <http://lemonldap-ng.org/>, Lemonldap::NG::Portal,
90       Lemonldap::NG::Handler, Plack, PSGI,
91       Lemonldap::NG::Common::PSGI::Router,
92       Lemonldap::NG::Common::PSGI::Request, HTML::Template,
93

AUTHORS

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

BUG REPORT

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

DOWNLOAD

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