2006-12-18 12:32:33 +01:00
|
|
|
package Lemonldap::NG::Portal::AuthSSL;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Lemonldap::NG::Portal::Simple;
|
|
|
|
|
2007-01-11 07:42:57 +01:00
|
|
|
our $VERSION = '0.04';
|
|
|
|
|
|
|
|
# Authentication is made by Apache with SSL and here before searching the LDAP
|
|
|
|
# Directory.
|
|
|
|
# So authenticate is overloaded to return only PE_OK.
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
our $OVERRIDE = {
|
2007-01-11 07:42:57 +01:00
|
|
|
# By default, authentication is valid if SSL_CLIENT_S_DN_Email environement
|
|
|
|
# variable is present. Adapt it if you want
|
2006-12-18 12:32:33 +01:00
|
|
|
extractFormInfo => sub {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{user} = $self->https('SSL_CLIENT_S_DN_Email');
|
|
|
|
return PE_BADCREDENTIALS unless ( $self->{user} );
|
|
|
|
PE_OK;
|
|
|
|
},
|
|
|
|
|
2007-01-11 07:42:57 +01:00
|
|
|
# As we know only user mail, we have to use it to find him in the LDAP
|
|
|
|
# directory
|
2006-12-18 12:32:33 +01:00
|
|
|
formateFilter => sub {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{filter} = "(&(mail=" . $self->{user} . ")(objectClass=person))";
|
|
|
|
PE_OK;
|
|
|
|
},
|
|
|
|
|
|
|
|
authenticate => sub {
|
|
|
|
PE_OK;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
1;
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
Lemonldap::NG::Portal::AuthSSL - Perl extension for building Lemonldap::NG
|
|
|
|
compatible portals with SSL authentication.
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2007-02-23 06:31:32 +01:00
|
|
|
With Lemonldap::NG::Portal::SharedConf, set authentication field to "SSL" in
|
|
|
|
configuration database.
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
With Lemonldap::NG::Portal::Simple:
|
|
|
|
|
|
|
|
use Lemonldap::NG::Portal::Simple;
|
|
|
|
my $portal = new Lemonldap::NG::Portal::Simple(
|
2007-01-14 20:39:07 +01:00
|
|
|
domain => 'gendarmerie.defense.gouv.fr',
|
2006-12-18 12:32:33 +01:00
|
|
|
globalStorage => 'Apache::Session::MySQL',
|
2007-01-14 20:39:07 +01:00
|
|
|
globalStorageOptions => {
|
|
|
|
DataSource => 'dbi:mysql:database',
|
|
|
|
UserName => 'db_user',
|
|
|
|
Password => 'db_password',
|
|
|
|
TableName => 'sessions',
|
|
|
|
},
|
|
|
|
ldapServer => 'ldap.domaine.com',
|
|
|
|
securedCookie => 1,
|
|
|
|
authentication => 'SSL',
|
2006-12-18 12:32:33 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
if($portal->process()) {
|
|
|
|
# Write here the menu with CGI methods. This page is displayed ONLY IF
|
|
|
|
# the user was not redirected here.
|
|
|
|
print $portal->header; # DON'T FORGET THIS (see CGI(3))
|
|
|
|
print "...";
|
|
|
|
|
|
|
|
# or redirect the user to the menu
|
|
|
|
print $portal->redirect( -uri => 'https://portal/menu');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# If the user enters here, IT MEANS THAT YOUR SSL PARAMETERS ARE BAD
|
|
|
|
print $portal->header; # DON'T FORGET THIS (see CGI(3))
|
|
|
|
print "<html><body><h1>Unable to work</h1>";
|
|
|
|
print "This server isn't well configured. Contact your administrator.";
|
|
|
|
print "</body></html>";
|
|
|
|
}
|
|
|
|
|
|
|
|
Modify your httpd.conf:
|
|
|
|
|
|
|
|
<Location /My/File>
|
|
|
|
SSLVerifyClient require
|
|
|
|
SSLOptions +ExportCertData +CompatEnvVars +StdEnvVars
|
|
|
|
</Location>
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
This library just overload few methods of Lemonldap::NG::Portal::Simple to use
|
|
|
|
Apache SSLv3 mechanism: we've just to verify that
|
|
|
|
C<$ENV{SSL_CLIENT_S_DN_Email}> exists. So remenber to export SSL variables
|
|
|
|
to CGI.
|
|
|
|
|
|
|
|
See L<Lemonldap::NG::Portal::Simple> for usage and other methods.
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
L<Lemonldap::NG::Portal>, L<Lemonldap::NG::Portal::Simple>
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
|
2007-02-23 06:31:32 +01:00
|
|
|
Copyright (C) 2005-2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.4 or,
|
|
|
|
at your option, any later version of Perl 5 you may have available.
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|