correct use clause and session dn
This commit is contained in:
parent
d0f545b666
commit
74fce152f8
|
@ -6,7 +6,9 @@ use warnings;
|
|||
|
||||
use Lemonldap::Config::Parameters;
|
||||
use Lemonldap::Portal::Standard;
|
||||
use Apache2::Const qw(FORBIDDEN OK SERVER_ERROR REDIRECT);
|
||||
use Apache2::Const qw(DONE FORBIDDEN OK SERVER_ERROR REDIRECT);
|
||||
use Apache2::Log();
|
||||
use APR::Table;
|
||||
|
||||
use Data::Dumper;
|
||||
use Template;
|
||||
|
@ -18,7 +20,7 @@ use Encode qw(encode);
|
|||
use Lemonldap::Portal::Session;
|
||||
use Net::LDAP::Entry;
|
||||
use IO::File;
|
||||
our $VERSION = '3.1.0';
|
||||
our $VERSION = '3.2';
|
||||
|
||||
my $client_addr;
|
||||
my $sessCacheRefreshPeriod;
|
||||
|
@ -75,6 +77,7 @@ sub My_Session {
|
|||
my %Session;
|
||||
|
||||
my $entry = $self->{entry};
|
||||
$self->{dn}= $entry->dn ;
|
||||
my $obj = Lemonldap::Portal::Session->init ($paramxml,'entry' =>$entry) ;
|
||||
$self->{infosession} = $obj;
|
||||
my $fh = IO::File->new_tmpfile ;
|
||||
|
@ -113,7 +116,7 @@ sub handler {
|
|||
$Login_Url = $Conf_Domain->{Portal};
|
||||
$Cookie_Name = $Conf_Domain->{Cookie};
|
||||
$page_html = $Conf_Domain->{LoginPage};
|
||||
$Ldap_Server = $Conf_Domain->{ldap_server};
|
||||
$Ldap_Server = $Conf_Domain->{ldap_server};
|
||||
$Ldap_Branch_People = $Conf_Domain->{ldap_branch_people};
|
||||
$Ldap_Dn_Manager = $Conf_Domain->{DnManager};
|
||||
$Ldap_Pass_Manager = $Conf_Domain->{passwordManager};
|
||||
|
@ -128,31 +131,13 @@ sub handler {
|
|||
$html = <$file>;
|
||||
close $file;
|
||||
}
|
||||
$ipCheck = $Conf_Domain->{ClientIPCheck};
|
||||
|
||||
|
||||
$inactivityTimeout = $Conf_Domain->{InactivityTimeout};
|
||||
$sessCacheRefreshPeriod = $Conf_Domain->{SessCacheRefreshPeriod};
|
||||
|
||||
$Ldap_Server = $Conf_Domain->{ldap_server};
|
||||
$Ldap_Branch_People = $Conf_Domain->{ldap_branch_people};
|
||||
$Ldap_Dn_Manager = $Conf_Domain->{DnManager};
|
||||
$Ldap_Pass_Manager = $Conf_Domain->{passwordManager};
|
||||
$Ldap_Port = $Conf_Domain->{ldap_port};
|
||||
|
||||
#<Recuperation de l'adresse IP cliente>
|
||||
if ($ipCheck){
|
||||
my $connection = $r->connection();
|
||||
$client_addr = $connection->remote_ip();
|
||||
}
|
||||
#</Recuperation de l'adresse IP cliente>
|
||||
|
||||
$UserAttributes = $r->dir_config('LdapUserAttributes');
|
||||
if (defined($r->dir_config('LdapUserAttributes'))){
|
||||
@attrs = split(/\s+/,$r->dir_config('LdapUserAttributes'));
|
||||
}else{
|
||||
@attrs = ();
|
||||
}
|
||||
|
||||
|
||||
$Ldap_Search_Bases = $Ldap_Branch_People;
|
||||
# if (defined($r->dir_config('LdapSearchBases'))){
|
||||
# $Ldap_Search_Bases = $r->dir_config('LdapSearchBases').":".$Ldap_Search_Bases;
|
||||
|
@ -161,28 +146,13 @@ sub handler {
|
|||
|
||||
$MemcachedServer = $Parameters->formateLineHash($Parameters->findParagraph('session','memcached')->{SessionParams});
|
||||
$CookieName = $Conf_Domain->{Cookie};
|
||||
$InactivityTimeout = $Conf_Domain->{InactivityTimeout};
|
||||
$Encryptionkey = $Conf_Domain->{Encryptionkey};
|
||||
$Menu = $Conf_Domain->{'Menu'};
|
||||
|
||||
$line_session = $Conf_Domain->{DefinitionSession};
|
||||
|
||||
$line_session = $Conf_Domain->{DefinitionSession};
|
||||
$Stack_User = Lemonldap::Portal::Standard->new(
|
||||
'msg' => $Messages,
|
||||
'setSessionInfo' => \&My_Session,
|
||||
# 'controlUrlOrigin' => \&my_none,
|
||||
'controlTimeOut' => \&my_none,
|
||||
# 'controlSyntax' => \&my_none,
|
||||
'controlIP' => \&my_none,
|
||||
# 'bind' => \&my_none,
|
||||
# 'formateFilter' =>\&my_none,
|
||||
# 'formateBaseLDAP' =>\&my_none,
|
||||
# 'contactServer' =>\&my_none,
|
||||
# 'search' =>\&my_entry,
|
||||
# 'unbind' =>\&my_none,
|
||||
# 'credentials' =>\&my_none,
|
||||
|
||||
);
|
||||
'controlTimeOut' => \&my_none,
|
||||
'controlIP' => \&my_none,
|
||||
);
|
||||
$Stack_User->{'AlreadyCreated'} = "true";
|
||||
$Stack_User->{line_session} = $line_session;
|
||||
|
||||
|
@ -191,30 +161,13 @@ sub handler {
|
|||
my $UrlCode;
|
||||
my $UrlDecode;
|
||||
my $Erreur;
|
||||
|
||||
my %Params ;
|
||||
my $buf;
|
||||
# copy POST data, if any
|
||||
if ( $r->method eq 'POST' ) {
|
||||
my $len = $r->header_in('Content-length');
|
||||
$r->read( $buf, $len );
|
||||
my @arams= split '&',$buf;
|
||||
for (@arams) {
|
||||
(my $cle,my $val) = /(.+?)=(.+)/;
|
||||
$Params{$cle}= $val if $cle;
|
||||
}
|
||||
} else {
|
||||
# method GET
|
||||
my %Params = Vars;
|
||||
|
||||
|
||||
my $buf= $r->args;
|
||||
my @arams= split '&',$buf;
|
||||
for (@arams) {
|
||||
(my $cle,my $val) = /(.+?)=(.+)/;
|
||||
$Params{$cle}= $val if $cle;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
my $l= Dumper (\%Params);
|
||||
my $Retour = $Stack_User->process( 'param' => \%Params,
|
||||
|
@ -238,8 +191,8 @@ sub handler {
|
|||
if ( $Erreur == 4 || $Erreur == 5 ){
|
||||
# If bad login or password, refresh the login page with no information
|
||||
$log->info("LemonLDAP: ".$Message);
|
||||
#$Message = 'Authentification echouée';
|
||||
$Message = '';
|
||||
$Message = 'Authentification echouée';
|
||||
#$Message = '';
|
||||
}
|
||||
|
||||
# Login Page sending
|
||||
|
@ -262,7 +215,7 @@ sub handler {
|
|||
# };
|
||||
|
||||
$r->content_type('text/html');
|
||||
$r->send_http_header;
|
||||
$r->print;
|
||||
|
||||
$r->print($html_ok);
|
||||
|
||||
|
@ -275,10 +228,6 @@ $r->print($html_ok);
|
|||
my $MyHashSession = $Retour->infoSession;
|
||||
my $l = Dumper($MyHashSession) ;
|
||||
|
||||
if (defined($sessCacheRefreshPeriod) && defined($inactivityTimeout)){
|
||||
$MemcachedServer->{timeout} = $sessCacheRefreshPeriod + $inactivityTimeout;
|
||||
}
|
||||
|
||||
my %Session;
|
||||
tie %Session, 'Apache::Session::Memorycached', undef, $MemcachedServer;
|
||||
foreach (keys %{$MyHashSession}){
|
||||
|
@ -309,28 +258,13 @@ $r->print($html_ok);
|
|||
#Positionnement de la valeur time_end
|
||||
$dump =$Retour->{dump};
|
||||
|
||||
my $val_test;
|
||||
|
||||
if(defined($InactivityTimeout) && $InactivityTimeout != 0 ){
|
||||
my $time_end = time() + $InactivityTimeout;
|
||||
if (defined($Encryptionkey)){
|
||||
my $timeout_key = $Encryptionkey;
|
||||
my $cipher = new Crypt::CBC(-key => $timeout_key,-cipher => 'Blowfish',-iv => 'lemonlda',-header => 'none');
|
||||
$time_end = $cipher->encrypt_hex($time_end);
|
||||
}
|
||||
#Chaine utilise comme separateur entre l'id de session et le time_end
|
||||
#concatenation des deux valeurs
|
||||
my $separator = "_";
|
||||
$val_test = $Session_Id.$separator.$time_end;
|
||||
}else{
|
||||
$val_test = $Session_Id;
|
||||
}
|
||||
|
||||
$log->info("Set-Cookie: -name => $CookieName -value => $val_test -domain => ".".$MyDomain -path => $PathCookie");
|
||||
$log->info("Set-Cookie: -name => $CookieName -value => $Session_Id -domain => ".".$MyDomain -path => $PathCookie");
|
||||
|
||||
my $LemonldapCookie = CGI::cookie(
|
||||
-name => $CookieName,
|
||||
-value => $val_test,
|
||||
-value => $Session_Id,
|
||||
-domain => ".".$MyDomain,
|
||||
-path => $PathCookie,
|
||||
);
|
||||
|
@ -339,22 +273,19 @@ $r->print($html_ok);
|
|||
|
||||
$UrlDecode = $Menu if ( $UrlDecode eq '' );
|
||||
if ($UrlDecode) {
|
||||
|
||||
#$UrlDecode =~ s/priv//g;
|
||||
$r->headers_out->add('Location' => $UrlDecode);
|
||||
$r->send_http_header;
|
||||
return REDIRECT;
|
||||
print CGI::header( -Refresh => '0; URL='.$UrlDecode, -cookie => $LemonldapCookie );
|
||||
return DONE;
|
||||
} else {
|
||||
$r->content_type('text/html');
|
||||
$r->headers_out->add( 'Set-Cookie' => $LemonldapCookie );
|
||||
$r->send_http_header;
|
||||
$r->print;
|
||||
$r->print(<<END1);
|
||||
<html>
|
||||
<head><title>lemonldap websso</title></head>
|
||||
<body>
|
||||
<h1>Hello in lemonldap websso 'world</h1>
|
||||
Congratulation your are enter in the lemonldap'world
|
||||
<p>Your id_session is :$val_test<p>
|
||||
<p>Your id_session is :$Session_Id<p>
|
||||
<p> Your session have been created like this :<br>
|
||||
$l<p>
|
||||
Your session stored on memcached server is like this :<br>
|
||||
|
|
Loading…
Reference in New Issue