2016-03-30 21:51:12 +02:00
|
|
|
##@class Lemonldap::NG::Portal::Main::Run
|
|
|
|
# Serve request part of Lemonldap::NG portal
|
|
|
|
#
|
|
|
|
# Methods:
|
|
|
|
# - handler(): verify that portal configuration is the same that the
|
|
|
|
# underlying handler configuration before launching
|
|
|
|
# Lemonldap::NG::Common::PSGI::Router::handler() (which parse
|
|
|
|
# routes)
|
2016-03-31 07:27:59 +02:00
|
|
|
#
|
|
|
|
# Entry points:
|
|
|
|
# - "/test": * authenticated() for already authenticated users
|
|
|
|
# + pleaseAuth() for others
|
2016-03-29 23:09:55 +02:00
|
|
|
package Lemonldap::NG::Portal::Main::Run;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
2016-03-30 21:51:15 +02:00
|
|
|
use Lemonldap::NG::Portal::Main::Request;
|
2016-03-29 23:09:55 +02:00
|
|
|
|
2016-03-30 21:51:12 +02:00
|
|
|
our $VERSION = '2.0.0';
|
|
|
|
|
|
|
|
sub handler {
|
2016-03-31 07:27:59 +02:00
|
|
|
my ( $self, $req ) = shift;
|
|
|
|
unless ($self->conf->{cfgNum}
|
|
|
|
and $self->conf->{cfgNum} eq HANDLER->lmConf->{cfgNum} )
|
|
|
|
{
|
|
|
|
$self->reloadConf();
|
2016-03-30 21:51:12 +02:00
|
|
|
}
|
2016-03-30 21:51:15 +02:00
|
|
|
bless $req, 'Lemonldap::NG::Portal::Main::Request';
|
2016-03-30 21:51:12 +02:00
|
|
|
return $self->SUPER::handler($req);
|
|
|
|
}
|
|
|
|
|
2016-03-31 07:27:59 +02:00
|
|
|
# CORE REST API
|
|
|
|
|
|
|
|
# Methods that handle /test
|
|
|
|
sub authenticated {
|
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
return $self->sendJSONresponse( $req, { status => 1 } );
|
|
|
|
}
|
|
|
|
|
|
|
|
sub pleaseAuth {
|
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
return $self->sendJSONresponse( $req, { status => 0 } );
|
|
|
|
}
|
|
|
|
|
|
|
|
# MAIN ENTRY POINTS
|
|
|
|
|
|
|
|
sub login {
|
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
return $self->process(
|
|
|
|
'rememberArgs', @{ $self->beforeAuthProcess },
|
|
|
|
@authProcess, @{ $self->addSessionData },
|
|
|
|
@sessionDatas, @{ $self->afterAuthProcess }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub postLogin {
|
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
return $self->process(
|
|
|
|
@{ $self->beforeAuthProcess },
|
|
|
|
@authProcess, @{ $self->addSessionData },
|
|
|
|
@sessionDatas, @{ $self->afterAuthProcess }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub authenticatedRequest {
|
|
|
|
}
|
|
|
|
|
2016-03-29 23:09:55 +02:00
|
|
|
# TODO in run
|
|
|
|
# - mustRedirect
|
2016-03-30 07:47:38 +02:00
|
|
|
# - store AuthnLevel in session (setSessionInfo)
|
|
|
|
# $self->{sessionInfo}->{authenticationLevel} = $self->_authentication->AuthnLevel
|
2016-03-29 23:09:55 +02:00
|
|
|
|
|
|
|
1;
|