AuthLLDAPSympa
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Apache2::AuthLLDAPSympa',
AUTHOR => 'Sebastien DIAZ <sebastien.diaz AT gmail.com>',
VERSION_FROM => 'lib/Apache2/AuthLLDAPSympa.pm',
ABSTRACT_FROM => 'lib/Apache2/AuthLLDAPSympa.pm',
PL_FILES => {},
PREREQ_PM => {
'CGI::More' => 0,
'CGI::Cookie' => 0;
'Apache2::Access' => 0,
'Apache2::SubRequest' => 0,
'Apache2::RequestRec' => 0,
'Apache2::RequestUtil' => 0,
'Apache2::Response' => 0,
'mod_perl2' => 0,
'Apache2::Log' => 0,
'Net::LDAP' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
lib/Apache2/AuthLLDAPSympa.pm view on Meta::CPAN
=cut
sub handler {
my $r=shift;
$fileLog=$r->dir_config('LemonLDAPSympaLogFile')||'LemonSympaPlu.log';
$logMode=$r->dir_config('LemonLDAPSympaLogMode')||'ERROR';
if ($fileLog eq "") { $fileLog='LemonSympaPlu.log';}
if ($logMode eq "") { $logMode='ERROR';}
&logDebug('Start the Handler');
my $myCookies=$r->headers_in->get('Cookie');
&logDebug("The cookies are:$myCookies");
my $auth = $r->header_in("Authorization");
&logDebug("The Authorization is:$auth");
my ($user, $pass);
if ($auth ne "")
{
$auth =~ s/Basic//;
($user, $pass)=split(/:/, decode_base64($auth));
}
&logDebug("The user is:$user");
#If Authentification and no cookie sympa user we add a new cookie sympauser
if ($auth ne "" && $user ne "" && $myCookies !~ /sympauser/)
{
&logDebug("There is no Cookie sympauser");
&logDebug("There user is:$user");
&logDebug("Read mod_perl parameters");
#Read the parameters for the plugin
my $LDAPHOST=$r->dir_config('LemonLDAPSympaHost');
my $LDAPFilter=$r->dir_config('LemonLDAPSympaFilter');
my $LDAPEmailAttr=$r->dir_config('LemonLDAPSympaEmailAttribute');
my $LDAPEmailSel=$r->dir_config('LemonLDAPSympaEmailSelect');
my $LemonConf=$r->dir_config('LemonLDAPSympaConfFile');
my $LemonWWConf=$r->dir_config('LemonLDAPSympaWWConfFile');
lib/Apache2/AuthLLDAPSympa.pm view on Meta::CPAN
use List;
use mail;
use smtp;
use Conf;
use Commands;
use Language;
use Log;
use Auth;
use admin ;
use CGI;
use CGI::Cookie ;
require $SympaToolScript;
## Configuration
my $wwsconf = {};
## Change to your wwsympa.conf location
my $conf_file = $LemonWWConf;
my $sympa_conf_file = $LemonConf;
my $robot ;
my $param;
my $ip;
lib/Apache2/AuthLLDAPSympa.pm view on Meta::CPAN
$param->{'cookie_domain'} = $Conf{'robots'}{$robot}{'cookie_domain'} if $Conf{'robots'}{$robot};
$param->{'cookie_domain'} ||= $wwsconf->{'cookie_domain'};
$ip = $ENV{'REMOTE_HOST'};
$ip = $ENV{'REMOTE_ADDR'} unless ($ip);
$ip = 'undef' unless ($ip);
## In case HTTP_HOST does not match cookie_domain
my $http_host = $ENV{'HTTP_HOST'};
$http_host =~ s/:\d+$//; ## suppress port
unless (($http_host =~ /$param->{'cookie_domain'}$/) ||
($param->{'cookie_domain'} eq 'localhost')) {
&wwslog('notice', 'Cookie_domain(%s) does NOT match HTTP_HOST; setting cookie_domain to %s', $param->{'cookie_domain'}, $http_host);
my $cookLog=$param->{'cookie_domain'};
&logDebug("Cookie_domain($cookLog=) does NOT match HTTP_HOST; setting cookie_domain to $http_host");
$param->{'cookie_domain'} = $http_host;
}
#The LDAP Traitment
&logDebug ("Load LDAP libraries");
use Net::LDAP;
#my($ldap) = Net::LDAP->new('ldpcentraledev.alize', port => 10389) or die "Can't bind to ldap: $!\n";
&logDebug ("Connect to LDAP");
lib/Apache2/AuthLLDAPSympa.pm view on Meta::CPAN
$delayL = 'session';
}
#Generate the cookie of Sympa
&logDebug ("Generate the cookie");
my $cookieVal= &set_cookie_ext($emailFinded, $Conf{'cookie'},$param->{'cookie_domain'}, $delayL, 'classic');
#my $cookieAltVal= &set_cookie_alte_ext($emailFinded, $Conf{'cookie'},$param->{'cookie_domain'}, $delayL, 'classic');
&logDebug ("The cookie is :$cookieVal");
#&logDebug ("The cookie Alte is :$cookieAltVal");
#$cookieVal="$cookieVal;$cookieAltVal"
$r->header_in('Cookie',"$myCookies;$cookieVal");
&logDebug ("The cookie is added to cookie List");
&logInfo ("The user $user is connected on Sympa with the email $emailFinded");
}
return Apache2::Const::OK;
}
## Set user $email cookie, ckecksum use $secret, expire=(now|session|#sec) domain=(localhost|<a domain>)
lib/Apache2/AuthLLDAPSympa.pm view on Meta::CPAN
if ($http_domain eq 'localhost') {
$http_domain="";
}
my $value = sprintf '%s:%s', $email, &get_mac_extra($email,$secret);
if ($auth ne 'classic') {
$value .= ':'.$auth;
}
my $cookie;
if ($expires =~ /session/i) {
$cookie = new CGI::Cookie (-name => 'sympauser',
-value => $value,
-domain => $http_domain,
-path => '/'
);
}else {
$cookie = new CGI::Cookie (-name => 'sympauser',
-value => $value,
-expires => $expiration,
-domain => $http_domain,
-path => '/'
);
}
## Send cookie to the client
return $cookie->as_string;
}
## Set user $email cookie, ckecksum use $secret, expire=(now|session|#sec) domain=(localhost|<a domain>)
lib/Apache2/AuthLLDAPSympa.pm view on Meta::CPAN
if ($http_domain eq 'localhost') {
$http_domain="";
}
my $value = sprintf '%s:%s', $email, &get_mac_extra($email,$secret);
if ($auth ne 'classic') {
$value .= ':'.$auth;
}
my $cookie;
if ($expires =~ /session/i) {
$cookie = new CGI::Cookie (-name => 'sympa_altemails',
-value => $value,
-domain => $http_domain,
-path => '/'
);
}else {
$cookie = new CGI::Cookie (-name => 'sympa_altemails',
-value => $value,
-expires => $expiration,
-domain => $http_domain,
-path => '/'
);
}
## Send cookie to the client
return $cookie->as_string;
}
sub get_mac_extra {
( run in 0.805 second using v1.01-cache-2.11-cpan-e9199f4ba4c )