2007-02-24 14:30:53 +01:00
|
|
|
package Lemonldap::NG::Handler::CDA;
|
2007-02-23 07:03:58 +01:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use Lemonldap::NG::Handler::SharedConf qw(:all);
|
|
|
|
|
2007-04-10 07:15:26 +02:00
|
|
|
our $VERSION = '0.02';
|
2007-02-23 07:03:58 +01:00
|
|
|
|
|
|
|
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 $args = $apacheRequest->args;
|
2007-04-10 07:15:26 +02:00
|
|
|
if ( $args =~ s/[\?&]?($cookieName=\w+)$//oi ) {
|
2007-02-23 07:03:58 +01:00
|
|
|
my $str = $1;
|
|
|
|
$class->lmLog(
|
|
|
|
"Found a CDA id. Redirecting "
|
2007-02-24 14:30:53 +01:00
|
|
|
. $apacheRequest->connection->remote_ip
|
|
|
|
. " to myself with new cookie",
|
|
|
|
'debug'
|
|
|
|
);
|
|
|
|
$apacheRequest->args($args);
|
|
|
|
my $host = $apacheRequest->get_server_name();
|
|
|
|
lmSetErrHeaderOut( $apacheRequest,
|
|
|
|
'Location' => "http"
|
|
|
|
. ( $https ? 's' : '' )
|
|
|
|
. "://$host"
|
|
|
|
. $apacheRequest->uri
|
|
|
|
. ( $apacheRequest->args ? "?" . $apacheRequest->args : "" ) );
|
|
|
|
$host =~ s/^[^\.]+\.(.*\..*$)/$1/;
|
|
|
|
lmSetErrHeaderOut( $apacheRequest,
|
|
|
|
'Set-Cookie' => "$str; domain=$host; path=/"
|
|
|
|
. ( $cookieSecured ? "; secure" : "" ) );
|
2007-02-23 07:34:29 +01:00
|
|
|
return REDIRECT;
|
|
|
|
}
|
|
|
|
else {
|
2007-02-24 14:30:53 +01:00
|
|
|
return $class->SUPER::run($apacheRequest);
|
2007-02-23 07:03:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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>,
|
2007-04-02 21:13:05 +02:00
|
|
|
L<Lemonldap::NG::Handler::SharedConf>,
|
|
|
|
http://wiki.lemonldap.objectweb.org/xwiki/bin/view/NG/Presentation
|
2007-02-23 07:03:58 +01:00
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
|
|
|
|
2007-04-14 15:12:11 +02:00
|
|
|
=head1 BUG REPORT
|
|
|
|
|
|
|
|
Use OW2 system to report bug or ask for features:
|
|
|
|
L<http://forge.objectweb.org/tracker/?group_id=274>
|
|
|
|
|
|
|
|
=head1 DOWNLOAD
|
|
|
|
|
|
|
|
Lemonldap::NG is available at
|
|
|
|
L<http://forge.objectweb.org/project/showfiles.php?group_id=274>
|
|
|
|
|
2007-02-23 07:03:58 +01:00
|
|
|
=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
|
|
|
|
|