From 74fce152f8b693f2170d22249917f16e48b108aa Mon Sep 17 00:00:00 2001 From: Eric German Date: Tue, 19 Jun 2007 11:28:40 +0000 Subject: [PATCH] correct use clause and session dn --- .../lib/Lemonldap/Portal/LoginFakeLDAP.pm | 117 ++++-------------- 1 file changed, 24 insertions(+), 93 deletions(-) diff --git a/modules/lemonldap-portal/lib/Lemonldap/Portal/LoginFakeLDAP.pm b/modules/lemonldap-portal/lib/Lemonldap/Portal/LoginFakeLDAP.pm index 8e226f0c6..5af5dc8dd 100755 --- a/modules/lemonldap-portal/lib/Lemonldap/Portal/LoginFakeLDAP.pm +++ b/modules/lemonldap-portal/lib/Lemonldap/Portal/LoginFakeLDAP.pm @@ -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}; - - # - if ($ipCheck){ - my $connection = $r->connection(); - $client_addr = $connection->remote_ip(); - } - # - - $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(< lemonldap websso

Hello in lemonldap websso 'world

Congratulation your are enter in the lemonldap'world -

Your id_session is :$val_test

+

Your id_session is :$Session_Id

Your session have been created like this :
$l

Your session stored on memcached server is like this :