Plugins.pm 2.47 KB
Newer Older
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';

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

use strict;
10 11 12 13
use Mouse;

# Plugins enabled by a simple boolean value (ordered list)
#
Christophe Maudoux's avatar
Christophe Maudoux committed
14
# Developers: 2FA must be loaded before Notifications
15
our @pList = (
Xavier Guimard's avatar
Xavier Guimard committed
16 17 18 19 20 21 22 23 24 25
    portalDisplayResetPassword => '::Plugins::MailReset',
    portalStatus               => '::Plugins::Status',
    cda                        => '::Plugins::CDA',
    notification               => '::Plugins::Notifications',
    portalCheckLogins          => '::Plugins::History',
    stayConnected              => '::Plugins::StayConnected',
    grantSessionRule           => '::Plugins::GrantSession',
    upgradeSession             => '::Plugins::Upgrade',
    autoSigninRules            => '::Plugins::AutoSignin',
    checkState                 => '::Plugins::CheckState',
26
);
Xavier Guimard's avatar
Xavier Guimard committed
27

28 29 30 31 32
##@method list enabledPlugins
#
#@return list of enabled plugins
sub enabledPlugins {
    my ($self) = @_;
33
    my $conf = $self->conf;
34 35
    my @res;

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

44 45
    # Load static plugin list
    for ( my $i = 0 ; $i < @pList ; $i += 2 ) {
46
        push @res, $pList[ $i + 1 ] if ( $conf->{ $pList[$i] } );
47
    }
48

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

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

Xavier Guimard's avatar
Xavier Guimard committed
61 62
    # Add REST (check is done by it)
    push @res, '::Plugins::RESTServer';
63

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

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

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

1;