Commit b6cdee5d authored by Yadd's avatar Yadd
Browse files

Now userNotice and userError are customizable like subs called by _subProcess

parent 415d23b6
......@@ -176,8 +176,6 @@ sub abort {
sub startSyslog {
my $self = shift;
return if ( $self->{_syslog} );
print STDERR "DEBUG : $self->{syslog}\n" . Dumper($self);
use Data::Dumper;
eval "use Sys::Syslog; openlog('lemonldap-ng','ndelay','$self->{syslog}');";
$self->abort( "Unable to use syslog", $@ ) if ($@);
$self->{_syslog} = 1;
......@@ -216,6 +214,22 @@ sub userError {
$self->userLog( $mess, 'warn' );
}
## @method protected scalar _sub(string sub, array p)
# Launch $self->{$sub} if defined, else launch $self->$sub.
# @param $sub name of the sub to launch
# @param @p parameters for the sub
sub _sub {
my ( $self, $sub, @p ) = @_;
if ( $self->{$sub} ) {
$self->lmLog( "processing to custom sub $sub", 'debug' );
return &{ $self->{$sub} }( $self, @p );
}
else {
$self->lmLog( "processing to sub $sub", 'debug' );
return $self->$sub(@p);
}
}
1;
__END__
......
......@@ -127,6 +127,7 @@ sub saveConf {
local $Data::Dumper::Indent = 0;
local $Data::Dumper::Varname = "data";
while ( my ( $k, $v ) = each(%$conf) ) {
next if ( $k =~ /^(?:reVHosts|cipher)$/ );
if ( ref($v) ) {
$fields->{$k} = Dumper($v);
$fields->{$k} =~ s/'/'/g;
......@@ -183,9 +184,21 @@ sub getConf {
$r = $self->getDBConf($args);
}
}
$r->{cipher} =
Lemonldap::NG::Common::Crypto->new( $r->{key} || 'lemonldap-ng-key',
Crypt::Rijndael::MODE_CBC() );
if ( $args->{clean} ) {
delete $r->{reVHosts};
}
else {
eval {
$r->{cipher} = Lemonldap::NG::Common::Crypto->new(
$r->{key} || 'lemonldap-ng-key',
Crypt::Rijndael::MODE_CBC()
);
};
if ($@) {
$msg = "Bad key : $@";
return 0;
}
}
return $r;
}
}
......
......@@ -20,6 +20,11 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
# directory => '/usr/local/lemonlda-ng/conf/'
#},
# LOG
# By default, all is logged in Apache file. To log user actions by
# syslog, just set syslog facility here:
#syslog => 'auth',
# SOAP FUNCTIONS
# Remove comment to activate SOAP Functions getCookies(user,pwd) and
# error(language, code)
......@@ -37,6 +42,10 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
#customFunctions => 'function1 function2',
#customFunctions => 'Package::func1 Package::func2',
# NOTIFICATIONS SERVICE
# Use it to be able to notify messages during authentication
#notification => 1,
# OTHERS
# You can also overload any parameter issued from manager
# configuration. Example:
......
......@@ -27,6 +27,11 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
# directory => '/usr/local/lemonlda-ng/conf/'
#},
# LOG
# By default, all is logged in Apache file. To log user actions by
# syslog, just set syslog facility here:
#syslog => 'auth',
# SOAP FUNCTIONS
# Remove comment to activate SOAP Functions getCookies(user,pwd) and
# error(language, code)
......
......@@ -38,7 +38,7 @@ sub extractFormInfo {
# Does nothing.
# @return Lemonldap::NG::Portal constant
sub authenticate {
$self->userNotice( "Good authentication for "
$self->_sub('userNotice', "Good authentication for "
. $self->{sessionInfo}->{ $self->{whatToTrace} } );
PE_OK;
}
......
......@@ -49,7 +49,7 @@ sub extractFormInfo {
# Does nothing.
# @return Lemonldap::NG::Portal constant
sub authenticate {
$self->userNotice( "Good authentication for "
$self->_sub('userNotice', "Good authentication for "
. $self->{sessionInfo}->{ $self->{whatToTrace} } );
PE_OK;
}
......
......@@ -82,7 +82,7 @@ sub authenticate {
]->[$pp_error];
}
else {
$self->userError("Bad password for $self->{user}");
$self->_sub('userError',"Bad password for $self->{user}");
return PE_BADCREDENTIALS;
}
}
......@@ -94,12 +94,12 @@ sub authenticate {
my $mesg =
$self->ldap->bind( $self->{dn}, password => $self->{password} );
if ( $mesg->code != 0 ) {
$self->userError("Bad password for $self->{user}");
$self->_sub('userError',"Bad password for $self->{user}");
return PE_BADCREDENTIALS;
}
}
$self->{sessionInfo}->{authenticationLevel} = 2;
$self->userNotice( "Good authentication for "
$self->_sub('userNotice', "Good authentication for "
. $self->{sessionInfo}->{ $self->{whatToTrace} } );
PE_OK;
}
......
......@@ -45,7 +45,7 @@ sub extractFormInfo {
return PE_OK;
}
elsif ( $self->{SSLRequire} ) {
$self->userError("No certificate found for $ENV{REMOTE_ADDR}");
$self->_sub('userError',"No certificate found for $ENV{REMOTE_ADDR}");
return PE_CERTIFICATEREQUIRED;
}
$self->{authFilter} = '';
......@@ -61,7 +61,7 @@ sub authenticate {
if ( $self->{sessionInfo}->{authenticationLevel}
and $self->{sessionInfo}->{authenticationLevel} > 4 )
{
$self->userNotice( "Good authentication for "
$self->_sub('userNotice', "Good authentication for "
. $self->{sessionInfo}->{ $self->{whatToTrace} } );
return PE_OK;
}
......
......@@ -382,17 +382,8 @@ sub _subProcess {
my $err = undef;
foreach my $sub (@subs) {
if ( $self->{$sub} ) {
$self->lmLog( "processing to custom sub $sub", 'debug' );
last if ( $err = &{ $self->{$sub} }($self) );
}
else {
$self->lmLog( "processing to sub $sub", 'debug' );
last if ( $err = $self->$sub );
last if($err = $self->_sub($sub));
}
}
return $err;
}
##@method protected void updateStatus()
......@@ -627,7 +618,7 @@ sub controlExistingSession {
@_,
);
$self->{error} = PE_REDIRECT;
$self->userNotice($self->{sessionInfo}->{$self->{whatToTrace}}." has been disconnected");
$self->_sub('userNotice', $self->{sessionInfo}->{$self->{whatToTrace}}." has been disconnected");
$self->_subProcess(qw(log autoRedirect));
return PE_FIRSTACCESS;
}
......
......@@ -56,7 +56,7 @@ sub search {
return PE_LDAPERROR;
}
unless ( $self->{entry} = $mesg->entry(0) ) {
$self->userError("$self->{user} was not found in LDAP directory");
$self->_sub('userError',"self->{user} was not found in LDAP directory");
return PE_BADCREDENTIALS;
}
$self->{dn} = $self->{entry}->dn();
......
Supports Markdown
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