New feature in Handler: Cross-Domain-Authentication (Lemonldap::NG::Handler::CDA).

WARNING: CDA.pm is not finished !
This commit is contained in:
Xavier Guimard 2007-02-23 06:03:58 +00:00
parent 9a8d380ad7
commit 4ad93eab3e
7 changed files with 137 additions and 5 deletions

View File

@ -3,6 +3,7 @@ example/lmH-apache.conf
example/lmH-apache2.conf
example/MyHandler.pm
lib/Lemonldap/NG/Handler.pm
lib/Lemonldap/NG/Handler/CDA.pm
lib/Lemonldap/NG/Handler/Proxy.pm
lib/Lemonldap/NG/Handler/SharedConf.pm
lib/Lemonldap/NG/Handler/SharedConf/DBI.pm
@ -12,6 +13,7 @@ Makefile.PL
MANIFEST
META.yml Module meta-data (added by MakeMaker)
README
t/Lemonldap-NG-Handler-CDA.t
t/Lemonldap-NG-Handler-Proxy.t
t/Lemonldap-NG-Handler-SharedConf-DBI.t
t/Lemonldap-NG-Handler-SharedConf.t

View File

@ -0,0 +1,114 @@
package Lemonldap::NG::Handler::SharedConf::DBI;
use strict;
use Lemonldap::NG::Handler::SharedConf qw(:all);
our $VERSION = '0.01';
our @ISA = qw(Lemonldap::NG::Handler::SharedConf);
*EXPORT_TAGS = *Lemonldap::NG::Handler::SharedConf::EXPORT_TAGS;
*EXPORT_OK = *Lemonldap::NG::Handler::SharedConf::EXPORT_OK;
sub run ($$) {
my $class;
( $class, $apacheRequest ) = @_;
#my $uri = $apacheRequest->uri . ( $apacheRequest->args ? "?" . $apacheRequest->args : "" );
my $args = $apacheRequest->args;
if ($args =~ /\?($cookieName=\w+)$/o) {
my $str = $1;
$class->lmLog(
"Found a CDA id. Redirecting "
. $apacheRequest->connection->remote_ip
. " to myself with new cookie",
'debug'
);
# TODO: https ?
$apacheRequest->headers_out->set( 'Location' => "http://".$apacheRequest->hostname );
# TODO: cookie secured ?
$apacheRequest->headers_out->set( 'Set-Cookie' => "$str" );
return REDIRECT;
}
}
1;
__END__
=head1 NAME
Lemonldap::NG::Handler::CDA - Module to use Lemonldap::NG::Handler
mechanisms with Cross-Domain-Authentication.
=head1 SYNOPSIS
New usage:
package My::Package;
use Lemonldap::NG::Handler::CDA;
@ISA = qw(Lemonldap::NG::Handler::CDA);
__PACKAGE__->init ( {
localStorage => "Cache::FileCache",
localStorageOptions => {
'namespace' => 'MyNamespace',
'default_expires_in' => 600,
},
reloadTime => 1200, # Default: 600
configStorage => {
type => "DBI"
dbiChain => "DBI:mysql:database=$database;host=$hostname;port=$port",
dbiUser => "lemonldap",
dbiPassword => "password",
},
} );
Call your package in /apache-dir/conf/httpd.conf :
PerlRequire MyFile
# TOTAL PROTECTION
PerlHeaderParserHandler My::Package
# OR SELECTED AREA
<Location /protected-area>
PerlHeaderParserHandler My::Package
</Location>
The configuration is loaded only at Apache start. Create an URI to force
configuration reload, so you don't need to restart Apache at each change :
# /apache-dir/conf/httpd.conf
<Location /location/that/I/ve/choosed>
Order deny,allow
Deny from all
Allow from my.manager.com
PerlHeaderParserHandler My::Package->refresh
</Location>
=head1 DESCRIPTION
This library inherit from L<Lemonldap::NG::Handler::SharedConf> and add the
capability to control users that are authenticated with a
L<Lemonldap::NG::portal::CDA> CGI in another domain.
=head2 EXPORT
Same as L<Lemonldap::NG::Handler::SharedConf>.
=head1 SEE ALSO
L<Lemonldap::NG::Manager>, L<Lemonldap::NG::Handler>,
L<Lemonldap::NG::Handler::SharedConf>
=head1 AUTHOR
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
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

View File

@ -223,7 +223,7 @@ local store.
=head1 SEE ALSO
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Handler::SharedConf::DBI>
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Manager>, L<Lemonldap::NG::Portal>
=back
@ -233,7 +233,7 @@ Xavier Guimard, E<lt>x.guimard@free.frE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2005 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
Copyright (C) 2005-2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
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,

View File

@ -186,7 +186,7 @@ Xavier Guimard, E<lt>x.guimard@free.frE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2005 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
Copyright (C) 2005-2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
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,

View File

@ -27,6 +27,7 @@ our %EXPORT_TAGS = (
lmHeaderOut
lmSetHeaderOut
lmSetErrHeaderOut
$cookieName
)
],
traces => [ qw( $whatToTrace ) ],
@ -707,7 +708,7 @@ Xavier Guimard, E<lt>x.guimard@free.frE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2005 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
Copyright (C) 2005-2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
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,

View File

@ -0,0 +1,15 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Handler-Proxy.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Handler::CDA') };
#########################
# 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.

View File

@ -27,7 +27,7 @@ sub existingSession {
sub autoRedirect {
my $self = shift;
my $tmp = $self->{domain};
$self->{urldc} .= ";".$self->{cookieName}."=".$self->{id} if($self->{urldc} !~ /$tmp$/oi);
$self->{urldc} .= "?".$self->{cookieName}."=".$self->{id} if($self->{urldc} !~ /$tmp$/oi);
return $self->SUPER::autoredirect(@_);
}