Commit ca16584d authored by Yadd's avatar Yadd
Browse files

#595 in progress...

parent 80f17a91
......@@ -26,7 +26,7 @@ sub init {
"Using demonstration mode, go in Manager to edit the configuration",
'warn' );
PE_OK;
1;
}
## @apmethod int authenticate()
......
......@@ -7,10 +7,11 @@ package Lemonldap::NG::Portal::Auth::_WebForm;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants;
our $VERSION = '2.0.0';
extends Lemonldap::NG::Portal::Main::Auth;
extends 'Lemonldap::NG::Portal::Main::Auth';
## @apmethod int authInit()
# Does nothing.
......
......@@ -6,7 +6,6 @@ use Mouse;
our $VERSION = '2.0.0';
extends(
'Lemonldap::NG::Handler::PSGI::Try',
'Lemonldap::NG::Portal::Main::Init',
'Lemonldap::NG::Portal::Main::Run',
);
......
......@@ -13,9 +13,13 @@ use Mouse;
use Lemonldap::NG::Common::Conf::Constants;
use Lemonldap::NG::Handler::Main::Reload qw/keepConf/;
use Lemonldap::NG::Portal::Main::Plugins;
use Regexp::Assemble;
our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Handler::PSGI::Try',
'Lemonldap::NG::Portal::Main::Plugins';
use constant HANDLER => 'Lemonldap::NG::Handler::PSGI::API';
# Configuration storage
......@@ -30,6 +34,9 @@ has _userDB => ( is => 'rw' );
has _macros => ( is => 'rw' );
has _groups => ( is => 'rw' );
# TrustedDomain regexp
has trustedDomains => ( is => 'rw' );
# Lists to store plugins entry-points
has beforeAuth => (
is => 'rw',
......@@ -80,7 +87,7 @@ sub init {
sub reloadConf {
my ($self) = @_;
my $conf = HANDLER->lmConf->{cfgNum};
my $conf = HANDLER->lmConf;
# Delete keys that will be generated
foreach my $key (
......@@ -135,10 +142,12 @@ sub reloadConf {
and $self->{"_$type"}->init );
}
$self->_authentication->authnLevel(
$self->conf->{ $self->conf->authentication . "AuthnLevel" } );
$self->conf->{ $self->conf->{authentication} . "AuthnLevel" } );
# Initialize trusted domain regexp
if ( $self->conf->{trustedDomains} =~ /^\s*\*\s*$/ ) {
if ( $self->conf->{trustedDomains}
and $self->conf->{trustedDomains} =~ /^\s*\*\s*$/ )
{
$self->trustedDomains(qr#^https?://#);
}
else {
......
......@@ -121,8 +121,8 @@ sub setSessionInfo {
my ( $self, $req ) = @_;
# Get the current user module
$req->{sessionInfo}->{_auth} = $self->getModule("auth");
$req->{sessionInfo}->{_userDB} = $self->getModule("user");
$req->{sessionInfo}->{_auth} = $self->getModule( $req, "auth" );
$req->{sessionInfo}->{_userDB} = $self->getModule( $req, "user" );
# Store IP address from remote address or X-FORWARDED-FOR header
$req->{sessionInfo}->{ipAddr} = $req->remote_ip;
......
......@@ -66,19 +66,19 @@ sub pleaseAuth {
sub login {
my ( $self, $req ) = @_;
return $req->do(
return $self->do(
$req,
[
'controlUrl', @{ $self->beforeAuth },
&authProcess, @{ $self->betweenAuthAndDatas },
&sessionDatas, @{ $self->afterdatas },
&sessionDatas, @{ $self->afterDatas },
]
);
}
sub postLogin {
my ( $self, $req ) = @_;
return $req->do(
return $self->do(
$req,
[
'restoreArgs', 'controlUrl',
......@@ -91,7 +91,7 @@ sub postLogin {
sub authenticatedRequest {
my ( $self, $req ) = @_;
return $req->do( $req, $self->forAuthUser );
return $self->do( $req, $self->forAuthUser );
}
# RUNNING METHODS
......
......@@ -6,8 +6,11 @@
package Lemonldap::NG::Portal::UserDB::Demo;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants;
extends Lemonldap::NG::Portal::Main::Module;
our $VERSION = '2.0.0';
## @apmethod int userDBInit()
......@@ -16,7 +19,7 @@ our $VERSION = '2.0.0';
sub init {
my $self = shift;
unless ( $self->get_module('auth') =~ /^Demo/ ) {
unless ( $self->p->getModule( undef, 'auth' ) =~ /^Demo/ ) {
$self->lmLog( "Use UserDBDemo only with AuthDemo", 'error' );
return PE_ERROR;
}
......@@ -40,7 +43,7 @@ sub init {
},
};
PE_OK;
1;
}
## @apmethod int getUser()
......
......@@ -3,6 +3,6 @@ use strict;
require 't/test-lib.pm';
print STDERR Dumper(&client);
print STDERR Dumper(&client->_get('/'));
done_testing( count() );
......@@ -51,6 +51,7 @@
"macros": {
"_whatToTrace": "$_auth eq 'SAML' ? \"$_user\\@$_idpConfKey\" : \"$_user\""
},
"notifications": 0,
"portal": "http://auth.example.com/",
"reloadUrls": {},
"userDB": "Demo",
......
......@@ -16,7 +16,7 @@ ok(
app => Lemonldap::NG::Portal::Main->run(
{
configStorage => { type => 'File', dirName => 't' },
logLevel => 'warn',
logLevel => 'debug',
cookieName => 'lemonldap',
securedCookie => 0,
https => 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment