pax_global_header00006660000000000000000000000064137251566420014525gustar00rootroot0000000000000052 comment=bdb716659fb0fc7ba438ac18fab907403d09f08c Apache-Session-LDAP-0.5/000077500000000000000000000000001372515664200147115ustar00rootroot00000000000000Apache-Session-LDAP-0.5/.travis.yml000066400000000000000000000002031372515664200170150ustar00rootroot00000000000000language: perl perl: - "5.22" - "5.20" - "5.18" - "5.16" - "5.14" notifications: irc: "irc.freenode.org#lemonldap-ng" Apache-Session-LDAP-0.5/COPYRIGHT000066400000000000000000000002371372515664200162060ustar00rootroot00000000000000Copyright (C) 2009-2020 by Xavier Guimard Copyright (C) 2014-2020 by Clement Oudot Copyright (C) 2019-2020 by Maxime Besson Copyright (C) 2018-2020 by Worteks Apache-Session-LDAP-0.5/Changes000066400000000000000000000011421372515664200162020ustar00rootroot00000000000000Revision history for Perl extension Apache::Session::LDAP. 0.5 Sun Sep 6 12:00:00 2020 - Add ldapVerify option for SSL cert validation (#4) - Add specific error handling for old versions (#5) 0.4 Fri Jun 12 12:00:00 2015 - Configuration of objectclass and attributes (#3) 0.3 Thu Oct 2 12:00:00 2014 - Always close connections on LDAP (#1) 0.2 Tue Jun 26 06:15:12 2012 - remove inappropriate comment 0.1 Wed Dec 8 16:30:32 2010 - change serialization 0.01 Sat Apr 18 19:02:01 2009 - original version; created by h2xs 1.23 with options -AXn Apache::Session::LDAP Apache-Session-LDAP-0.5/LICENSE000066400000000000000000000003201372515664200157110ustar00rootroot00000000000000This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. Apache-Session-LDAP-0.5/MANIFEST000066400000000000000000000003071372515664200160420ustar00rootroot00000000000000Changes Makefile.PL MANIFEST README t/Apache-Session-LDAP.t lib/Apache/Session/LDAP.pm lib/Apache/Session/Store/LDAP.pm META.yml Module meta-data (added by MakeMaker) Apache-Session-LDAP-0.5/META.yml000066400000000000000000000011201372515664200161540ustar00rootroot00000000000000--- #YAML:1.0 name: Apache-Session-LDAP version: 0.2 abstract: An implementation of Apache::Session author: - Xavier Guimard license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Apache::Session: 0 Net::LDAP: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.57_05 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Apache-Session-LDAP-0.5/Makefile.PL000066400000000000000000000012151372515664200166620ustar00rootroot00000000000000use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Apache::Session::LDAP', VERSION_FROM => 'lib/Apache/Session/LDAP.pm', # finds $VERSION PREREQ_PM => { 'Net::LDAP' => 0, 'Apache::Session' => 0, }, ( $] >= 5.005 ? ## Add these new keywords supported since 5.005 ( ABSTRACT_FROM => 'lib/Apache/Session/LDAP.pm', # retrieve abstract from module AUTHOR => 'Xavier Guimard ' ) : () ), ); Apache-Session-LDAP-0.5/README.md000066400000000000000000000007541372515664200161760ustar00rootroot00000000000000# Apache::Session::LDAP [![Build Status](https://travis-ci.org/LemonLDAPNG/Apache-Session-LDAP.svg?branch=master)](https://travis-ci.org/LemonLDAPNG/Apache-Session-LDAP) Store sessions in an LDAP directory. ## Installation To install this module type the following: ```` perl Makefile.PL make make test make install ```` ## Dependencies This module requires these other modules and libraries: * Apache::Session * Net::LDAP ## CPAN See http://search.cpan.org/dist/Apache-Session-LDAP/ Apache-Session-LDAP-0.5/lib/000077500000000000000000000000001372515664200154575ustar00rootroot00000000000000Apache-Session-LDAP-0.5/lib/Apache/000077500000000000000000000000001372515664200166405ustar00rootroot00000000000000Apache-Session-LDAP-0.5/lib/Apache/Session/000077500000000000000000000000001372515664200202635ustar00rootroot00000000000000Apache-Session-LDAP-0.5/lib/Apache/Session/LDAP.pm000066400000000000000000000036451372515664200213510ustar00rootroot00000000000000package Apache::Session::LDAP; use strict; use vars qw(@ISA $VERSION); $VERSION = '0.5'; @ISA = qw(Apache::Session); use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Store::LDAP; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Store::LDAP $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::MD5::generate; $self->{validate} = \&Apache::Session::Generate::MD5::validate; $self->{serialize} = \&Apache::Session::Serialize::Base64::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Base64::unserialize; return $self; } 1; =pod =head1 NAME Apache::Session::LDAP - An implementation of Apache::Session =head1 SYNOPSIS use Apache::Session::LDAP; tie %hash, 'Apache::Session::LDAP', $id, { ldapServer => 'ldap://localhost:389', ldapConfBase => 'dmdName=applications,dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', ldapObjectClass => 'applicationProcess', ldapAttributeId => 'cn', ldapAttributeContent => 'description', ldapVerify => 'require', ldapCAFile => '/etc/ssl/certs/ca-certificates.crt', }; =head1 DESCRIPTION This module is an implementation of Apache::Session. It uses an LDAP directory to store datas. =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE Copyright (C) 2009, 2012 by Xavier Guimard Copyright (C) 2014, 2015 by Clement Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =head1 SEE ALSO L =cut Apache-Session-LDAP-0.5/lib/Apache/Session/Store/000077500000000000000000000000001372515664200213575ustar00rootroot00000000000000Apache-Session-LDAP-0.5/lib/Apache/Session/Store/LDAP.pm000066400000000000000000000160211372515664200224350ustar00rootroot00000000000000package Apache::Session::Store::LDAP; use strict; use vars qw($VERSION); use Net::LDAP; $VERSION = '0.5'; sub new { my $class = shift; return bless {}, $class; } sub insert { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; my $msg = $self->ldap->add( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, attrs => [ objectClass => $self->{args}->{ldapObjectClass}, $self->{args}->{ldapAttributeId} => $session->{data}->{_session_id}, $self->{args}->{ldapAttributeContent} => $session->{serialized}, ], ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); } sub update { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; my $msg = $self->ldap->modify( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, replace => { $self->{args}->{ldapAttributeContent} => $session->{serialized}, }, ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); } sub materialize { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; my $msg = $self->ldap->search( base => $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, filter => '(objectClass=' . $self->{args}->{ldapObjectClass} . ')', scope => 'base', attrs => [ $self->{args}->{ldapAttributeContent} ], ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); eval { $session->{serialized} = $msg->shift_entry() ->get_value( $self->{args}->{ldapAttributeContent} ); }; if ( !defined $session->{serialized} ) { die "Object does not exist in data store"; } } sub remove { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->ldap->delete( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase} ); $self->ldap->unbind() && delete $self->{ldap}; } sub ldap { my $self = shift; return $self->{ldap} if ( $self->{ldap} ); # Parse servers configuration my $useTls = 0; my $tlsParam; my @servers = (); foreach my $server ( split /[\s,]+/, $self->{args}->{ldapServer} ) { if ( $server =~ m{^ldap\+tls://([^/]+)/?\??(.*)$} ) { $useTls = 1; $server = $1; $tlsParam = $2 || ""; } else { $useTls = 0; } push @servers, $server; } # Compatibility my $caFile = $self->{args}->{ldapCAFile} || $self->{args}->{caFile}; my $caPath = $self->{args}->{ldapCAPath} || $self->{args}->{caPath}; # Connect my $ldap = Net::LDAP->new( \@servers, onerror => undef, verify => $self->{args}->{ldapVerify} || "require", ( $caFile ? ( cafile => $caFile ) : () ), ( $caPath ? ( capath => $caPath ) : () ), ( $self->{args}->{ldapPort} ? ( port => $self->{args}->{ldapPort} ) : () ), ) or die( 'Unable to connect to ' . join( ' ', @servers ) . ': ' . $@ ); # Check SSL error for old Net::LDAP versions if ( $Net::LDAP::VERSION < '0.64' ) { # CentOS7 has a bug in which IO::Socket::SSL will return a broken # socket when certificate validation fails. Net::LDAP does not catch # it, and the process ends up crashing. # As a precaution, make sure the underlying socket is doing fine: if ( $ldap->socket->isa('IO::Socket::SSL') and $ldap->socket->errstr < 0 ) { die( "SSL connection error: " . $ldap->socket->errstr ); } } # Start TLS if needed if ($useTls) { my %h = split( /[&=]/, $tlsParam ); $h{verify} ||= ( $self->{args}->{ldapVerify} || "require" ); $h{cafile} ||= $caFile if ($caFile); $h{capath} ||= $caPath if ($caPath); my $start_tls = $ldap->start_tls(%h); if ( $start_tls->code ) { $self->logError($start_tls); return; } } # Bind with credentials my $bind = $ldap->bind( $self->{args}->{ldapBindDN}, password => $self->{args}->{ldapBindPassword} ); if ( $bind->code ) { $self->logError($bind); return; } $self->{ldap} = $ldap; return $ldap; } sub logError { my $self = shift; my $ldap_operation = shift; die "LDAP error " . $ldap_operation->code . ": " . $ldap_operation->error; } 1; =pod =head1 NAME Apache::Session::Store::LDAP - Use LDAP to store persistent objects =head1 SYNOPSIS use Apache::Session::Store::LDAP; my $store = new Apache::Session::Store::LDAP; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); =head1 DESCRIPTION This module fulfills the storage interface of Apache::Session. The serialized objects are stored in an LDAP directory file using the Net::LDAP Perl module. =head1 OPTIONS This module requires one argument in the usual Apache::Session style. The keys ldapServer, ldapBase, ldapBindDN, ldapBindPassword are required. The keys ldapPort, ldapObjectClass, ldapAttributeId, ldapAttributeContent are optional. Example: tie %s, 'Apache::Session::LDAP', undef, { ldapServer => 'localhost', ldapBase => 'dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', ldapObjectClass => 'applicationProcess', ldapAttributeId => 'cn', ldapAttributeContent => 'description', }; =head1 AUTHOR Xavier Guimard, Eguimard@E =head1 COPYRIGHT AND LICENSE Copyright (C) 2009, 2012 by Xavier Guimard Copyright (C) 2014, 2015 by Clement Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =head1 SEE ALSO L =cut Apache-Session-LDAP-0.5/rpm/000077500000000000000000000000001372515664200155075ustar00rootroot00000000000000Apache-Session-LDAP-0.5/rpm/Apache-Session-LDAP.spec000066400000000000000000000037711372515664200217130ustar00rootroot00000000000000#============================================================================== # Specification file for Apache::Session::LDAP #============================================================================== %define real_name Apache-Session-LDAP %define real_version 0.5 #============================================================================== # Main package #============================================================================== Name: perl-%{real_name} Version: %{real_version} Release: 1%{?dist} Summary: LDAP implementation of Apache::Session Group: Applications/System License: GPL+ or Artistic URL: http://search.cpan.org/dist/Apache-Session-LDAP/ Source0: http://search.cpan.org/CPAN/authors/id/C/CO/COUDOT/%{real_name}-%{real_version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} BuildArch: noarch BuildRequires: perl BuildRequires: perl(Apache::Session) BuildRequires: perl(ExtUtils::MakeMaker) BuildRequires: perl(Net::LDAP) Requires: perl(Apache::Session) Requires: perl(Net::LDAP) %description LDAP implementation of Apache::Session. Sessions are stored as LDAP entries inside a branch. %prep %setup -n %{real_name}-%{real_version} -q %build perl Makefile.PL INSTALLDIRS="vendor" %{__make} %{?_smp_mflags} %install rm -rf %{buildroot} %{__make} %{?_smp_mflags} %{__make} %{?_smp_mflags} install DESTDIR=%{buildroot} # Remove some unwanted files find %{buildroot} -name .packlist -exec rm -f {} \; find %{buildroot} -name perllocal.pod -exec rm -f {} \; %check %{__make} %{?_smp_mflags} test %files %defattr(-,root,root,-) %doc %{_mandir}/man3/Apache::Session::*.3pm.gz %{perl_vendorlib}/Apache/Session/LDAP.pm %{perl_vendorlib}/Apache/Session/Store/LDAP.pm %changelog * Sun Sep 06 2020 Clement Oudot - 0.5-1 - Update to 0.5 * Tue Jan 23 2018 Clement Oudot - 0.4-1 - Update to 0.4 * Mon Jan 12 2015 Clement Oudot - 0.3-1 - First package for 0.3 Apache-Session-LDAP-0.5/t/000077500000000000000000000000001372515664200151545ustar00rootroot00000000000000Apache-Session-LDAP-0.5/t/Apache-Session-LDAP.t000066400000000000000000000007521372515664200206650ustar00rootroot00000000000000# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Apache-Session-LDAP.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; BEGIN { use_ok('Apache::Session::LDAP') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script.