File: LemonldapNG.pm

package info (click to toggle)
lemonldap-ng 2.21.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,024 kB
  • sloc: perl: 77,414; javascript: 25,284; xml: 6,473; makefile: 1,303; sh: 453; sql: 159; python: 53; php: 26
file content (136 lines) | stat: -rw-r--r-- 3,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package Plack::Middleware::Auth::LemonldapNG;

our $AUTHORITY = 'cpan:GUIMARD';
our $VERSION   = '2.21.0';
our $llclass   = 'Lemonldap::NG::Handler::Server';

use strict;
use base qw(Plack::Middleware);
use Plack::Util;
use Plack::Util::Accessor qw(
  llhandler
  llparams
  on_reject
);

sub prepare_app {
    my ($self) = @_;
    Plack::Util::load_class($llclass);
    $self->llhandler( $llclass->run( $self->llparams ) );
}

sub call {
    my ( $self, $env ) = @_;
    my $res    = $self->llhandler->($env);
    my $rejApp = $self->on_reject;
    unless ( $res->[0] == 200 ) {
        if ($rejApp) {
            return $self->$rejApp( $env, $res );
        }
        else {
            return $res;
        }
    }
    my $app  = $self->app;
    @_ = $env;
    goto $app;
}

__PACKAGE__;
__END__

=pod

=encoding utf8

=head1 NAME

Plack::Middleware::Auth::LemonldapNG - authentication middleware for Lemonldap-NG

=head1 SYNOPSIS

  use Plack::Builder;
  
  my $app   = sub { ... };

  # Optionally ($proposedResponse is the PSGI response of Lemonldap::NG handler)
  #sub on_reject {
  #    my($self,$env,$proposedResponse) = @_;
  #    ...
  #}
  
  builder
  {
    enable "Auth::LemonldapNG";
    # Or with some LLNG args or a reject sub
    #enable "Auth::LemonldapNG",
    #  llparams => {
    #    configStorage => ...
    #  },
    #  on_reject => \&on_reject;
    $app;
  };

  # Or through OO Interface
  my $builder = Plack::Builder->new();
  $builder->add_middleware(
      "Auth::LemonldapNG",
      llparams => {
        configStorage => ...
      },
      on_reject => \&on_reject
  );
  $protected_app = $builder->wrap($app);

=head1 DESCRIPTION

Lemonldap::NG is a modular Web-SSO based on Apache::Session modules. It
simplifies the build of a protected area with a few changes in the application.

It manages both authentication and authorization and provides headers for
accounting. So you can have a full AAA protection for your web space as
described below.

Plack::Middleware::Auth::LemonldapNG provides the module to protect a L<Plack>
family server.

=head1 SEE ALSO

L<http://lemonldap-ng.org>, L<Plack>, L<Plack::Middleware>

=head1 AUTHORS

=over

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

=back

=head1 BUG REPORT

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

=head1 DOWNLOAD

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

=head1 COPYRIGHT AND LICENSE

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 L<http://www.gnu.org/licenses/>.

=cut