Plugins.pm 2.57 KB
Newer Older
Yadd's avatar
Yadd committed
1
2
3
4
5
6
# This module loads known enabled plugins. To add custom modules, just add them
# into "plugins" list in lemonldap-ng.ini, section "portal"
package Lemonldap::NG::Portal::Main::Plugins;

our $VERSION = '2.0.0';

Yadd's avatar
Yadd committed
7
8
9
package Lemonldap::NG::Portal::Main;

use strict;
Yadd's avatar
Yadd committed
10
11
12
13
14
15
16
17
18
19
use Mouse;

# Plugins enabled by a simple boolean value (ordered list)
#
# Developers: U2F must be loaded before Notifications
our @pList = (
    portalDisplayResetPassword => '::Plugins::MailReset',
    portalStatus               => '::Plugins::Status',
    cda                        => '::Plugins::CDA',
    u2fActivation              => '::Plugins::U2F',
Yadd's avatar
Yadd committed
20
    ext2fActivation            => '::Plugins::External2F',
Yadd's avatar
Yadd committed
21
22
    u2fSelfRegistration        => '::Register::U2F',
    notification               => '::Plugins::Notifications',
Yadd's avatar
Yadd committed
23
    portalCheckLogins          => '::Plugins::History',
Yadd's avatar
Yadd committed
24
    stayConnected              => '::Plugins::StayConnected',
Yadd's avatar
Yadd committed
25
    grantSessionRule           => '::Plugins::GrantSession',
Yadd's avatar
Yadd committed
26
    upgradeSession             => '::Plugins::Upgrade',
Yadd's avatar
Yadd committed
27
    autoSigninRules            => '::Plugins::AutoSignin',
Yadd's avatar
Yadd committed
28
);
Yadd's avatar
Yadd committed
29

Yadd's avatar
Yadd committed
30
31
32
33
34
##@method list enabledPlugins
#
#@return list of enabled plugins
sub enabledPlugins {
    my ($self) = @_;
Yadd's avatar
Yadd committed
35
    my $conf = $self->conf;
Yadd's avatar
Yadd committed
36
37
    my @res;

Yadd's avatar
Yadd committed
38
    # Search for Issuer* modules enabled
Yadd's avatar
Yadd committed
39
    foreach my $key (qw(SAML OpenID CAS OpenIDConnect Get)) {
Yadd's avatar
Yadd committed
40
        if ( $conf->{"issuerDB${key}Activation"} ) {
Yadd's avatar
Yadd committed
41
            $self->logger->debug("Issuer${key} enabled");
Yadd's avatar
Yadd committed
42
            push @res, "::Issuer::$key";
Yadd's avatar
Yadd committed
43
44
45
        }
    }

Yadd's avatar
Yadd committed
46
47
    # Load static plugin list
    for ( my $i = 0 ; $i < @pList ; $i += 2 ) {
Yadd's avatar
Yadd committed
48
        push @res, $pList[ $i + 1 ] if ( $conf->{ $pList[$i] } );
Yadd's avatar
Yadd committed
49
    }
Yadd's avatar
Yadd committed
50

Yadd's avatar
Yadd committed
51
52
53
54
55
56
57
    # Load single session
    push @res, '::Plugins::SingleSession'
      if ( $conf->{singleSession}
        or $conf->{singleIP}
        or $conf->{singleUserByIP}
        or $conf->{notifyOther} );

Yadd's avatar
Yadd committed
58
    # Check if SOAP is enabled
59
    push @res, '::Plugins::SOAPServer'
Yadd's avatar
Yadd committed
60
61
      if ( $conf->{soapSessionServer}
        or $conf->{soapConfigServer} );
Yadd's avatar
Yadd committed
62

Yadd's avatar
Yadd committed
63
64
    # Add REST (check is done by it)
    push @res, '::Plugins::RESTServer';
Yadd's avatar
Yadd committed
65

Yadd's avatar
Yadd committed
66
    if ( my $p = $conf->{passwordDB} ) {
Yadd's avatar
Yadd committed
67
68
        push @res, "::Password::$p" if ( $p ne 'Null' );
    }
Yadd's avatar
Yadd committed
69

Yadd's avatar
Yadd committed
70
71
    # Check if register is enabled
    push @res, '::Plugins::Register'
Yadd's avatar
Yadd committed
72
      if ( $conf->{registerDB} and $conf->{registerDB} ne 'Null' );
Yadd's avatar
Yadd committed
73

Yadd's avatar
Yadd committed
74
    # Check if custom plugins are required
Yadd's avatar
Yadd committed
75
    # TODO: change this name
Yadd's avatar
Yadd committed
76
77
78
    if ( $conf->{customPlugins} ) {
        $self->logger->debug( 'Custom plugins: ' . $conf->{customPlugins} );
        push @res, grep ( /\w/, split( /,\s*/, $conf->{customPlugins} ) );
Yadd's avatar
Yadd committed
79
    }
Yadd's avatar
Yadd committed
80
    return @res;
Yadd's avatar
Yadd committed
81
82
83
}

1;