LDAP in progress (#595)
This commit is contained in:
parent
39c6713aea
commit
13f24796b8
|
@ -0,0 +1,40 @@
|
|||
package Lemonldap::NG::Portal::Auth::LDAP;
|
||||
|
||||
use strict;
|
||||
use Mouse;
|
||||
|
||||
our $VERSION = '2.0.0';
|
||||
|
||||
# Inheritance: UserDB::LDAP provides all needed ldap function
|
||||
extends
|
||||
qw(Lemonldap::NG::Portal::Auth::_WebForm Lemonldap::NG::Portal::UserDB::LDAP);
|
||||
|
||||
sub authenticate {
|
||||
unless ( $self->ldap ) {
|
||||
return PE_LDAPCONNECTFAILED;
|
||||
}
|
||||
|
||||
# Set the dn unless done before
|
||||
unless ( $req->datas->{dn} ) {
|
||||
if ( my $tmp = $self->getUser($req) ) {
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
my $res =
|
||||
$self->ldap->userBind( $req->datas->{dn}, password => $req->{password} );
|
||||
|
||||
# Remember password if password reset needed
|
||||
$req->datas->{oldpassword} = $self->{password}
|
||||
if ( $res == PE_PP_CHANGE_AFTER_RESET );
|
||||
|
||||
$self->ldap->unbind;
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
sub authLogout {
|
||||
PE_OK;
|
||||
}
|
||||
|
||||
1;
|
|
@ -50,31 +50,31 @@ sub extractFormInfo {
|
|||
if ( $defUser && $defOldPassword ) {
|
||||
return PE_PASSWORDFORMEMPTY
|
||||
unless ( ( $req->{user} = $req->param('user') )
|
||||
&& ( $req->{oldpassword} = $req->param('oldpassword') )
|
||||
&& ( $req->{newpassword} = $req->param('newpassword') )
|
||||
&& ( $req->{confirmpassword} = $req->param('confirmpassword') ) );
|
||||
&& ( $req->datas->{oldpassword} = $req->param('oldpassword') )
|
||||
&& ( $req->datas->{newpassword} = $req->param('newpassword') )
|
||||
&& ( $req->datas->{confirmpassword} = $req->param('confirmpassword') ) );
|
||||
}
|
||||
|
||||
# 4. Captcha for login form
|
||||
if ( $self->conf->{captcha_login_enabled} && $defUser && $defPassword ) {
|
||||
$req->{captcha_user_code} = $req->param('captcha_user_code');
|
||||
$req->{captcha_check_code} = $req->param('captcha_code');
|
||||
$req->datas->{captcha_user_code} = $req->param('captcha_user_code');
|
||||
$req->datas->{captcha_check_code} = $req->param('captcha_code');
|
||||
|
||||
unless ( $req->{captcha_user_code} && $req->{captcha_check_code} ) {
|
||||
unless ( $req->datas->{captcha_user_code} && $req->datas->{captcha_check_code} ) {
|
||||
$self->lmLog( "Captcha not filled", 'warn' );
|
||||
return PE_CAPTCHAEMPTY;
|
||||
}
|
||||
|
||||
$self->lmLog(
|
||||
"Captcha data received: "
|
||||
. $req->{captcha_user_code} . " and "
|
||||
. $req->{captcha_check_code},
|
||||
. $req->datas->{captcha_user_code} . " and "
|
||||
. $req->datas->{captcha_check_code},
|
||||
'debug'
|
||||
);
|
||||
|
||||
# Check captcha
|
||||
my $captcha_result = $self->checkCaptcha( $req->{captcha_user_code},
|
||||
$req->{captcha_check_code} );
|
||||
my $captcha_result = $self->checkCaptcha( $req->datas->{captcha_user_code},
|
||||
$req->datas->{captcha_check_code} );
|
||||
|
||||
if ( $captcha_result != 1 ) {
|
||||
if ( $captcha_result == -3
|
||||
|
@ -97,7 +97,7 @@ sub extractFormInfo {
|
|||
}
|
||||
|
||||
# Other parameters
|
||||
$req->{timezone} = $req->param('timezone');
|
||||
$req->datas->{timezone} = $req->param('timezone');
|
||||
|
||||
PE_OK;
|
||||
}
|
||||
|
|
|
@ -112,6 +112,11 @@ sub checkLogout {
|
|||
PE_OK;
|
||||
}
|
||||
|
||||
sub authLogout {
|
||||
my $self = shift;
|
||||
return $self->_authentication->authLogout(@_);
|
||||
}
|
||||
|
||||
sub deleteSession {
|
||||
my ( $self, $req ) = @_;
|
||||
my $apacheSession = $self->getApacheSession( $req->id );
|
||||
|
|
|
@ -106,7 +106,8 @@ sub postAuthenticatedRequest {
|
|||
|
||||
sub logout {
|
||||
my ( $self, $req ) = @_;
|
||||
return $self->do( $req, [ @{ $self->beforeLogout }, 'deleteSession' ] );
|
||||
return $self->do( $req,
|
||||
[ @{ $self->beforeLogout }, 'authLogout', 'deleteSession' ] );
|
||||
}
|
||||
|
||||
# RUNNING METHODS
|
||||
|
|
Loading…
Reference in New Issue