2008-12-03 14:27:30 +01:00
|
|
|
## @file
|
|
|
|
# Main portal for Lemonldap::NG portal
|
|
|
|
#
|
|
|
|
# @copy 2005, 2006, 2007, 2008, Xavier Guimard <x.guimard@free.fr>
|
|
|
|
|
|
|
|
## @class
|
|
|
|
# Main portal for Lemonldap::NG portal
|
2006-12-18 12:32:33 +01:00
|
|
|
package Lemonldap::NG::Portal::SharedConf;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Lemonldap::NG::Portal::Simple qw(:all);
|
2008-11-17 17:59:56 +01:00
|
|
|
use Lemonldap::NG::Common::Conf;
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
*EXPORT_OK = *Lemonldap::NG::Portal::Simple::EXPORT_OK;
|
|
|
|
*EXPORT_TAGS = *Lemonldap::NG::Portal::Simple::EXPORT_TAGS;
|
|
|
|
*EXPORT = *Lemonldap::NG::Portal::Simple::EXPORT;
|
|
|
|
|
2008-12-25 09:04:33 +01:00
|
|
|
our $VERSION = "0.5";
|
2008-12-03 14:27:30 +01:00
|
|
|
use base qw(Lemonldap::NG::Portal::Simple);
|
2006-12-18 12:32:33 +01:00
|
|
|
|
2007-01-11 07:42:57 +01:00
|
|
|
##################
|
2007-01-13 20:34:03 +01:00
|
|
|
# OVERLOADED SUB #
|
2007-01-11 07:42:57 +01:00
|
|
|
##################
|
|
|
|
|
2008-12-29 11:28:31 +01:00
|
|
|
## @method boolean getConf(hashRef args)
|
2008-12-26 18:58:48 +01:00
|
|
|
# Copy all parameters returned by the Lemonldap::NG::Common::Conf object in $self.
|
|
|
|
# @param args hash
|
2008-12-28 09:36:52 +01:00
|
|
|
# @return True
|
2006-12-18 12:32:33 +01:00
|
|
|
sub getConf {
|
|
|
|
my $self = shift;
|
2007-02-28 23:36:19 +01:00
|
|
|
my %args;
|
|
|
|
if ( ref( $_[0] ) ) {
|
|
|
|
%args = %{ $_[0] };
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
%args = @_;
|
|
|
|
}
|
|
|
|
%$self = ( %$self, %args );
|
2008-04-10 11:40:16 +02:00
|
|
|
|
2008-04-10 11:34:21 +02:00
|
|
|
# For better performance the Portal can use the configuration stored in
|
|
|
|
# the local file system by the handlers. This can be used when
|
|
|
|
# configuration is not local (type DBI or SOAP)
|
2008-04-10 11:40:16 +02:00
|
|
|
my $tmp = 0;
|
|
|
|
unless ($tmp) {
|
|
|
|
$self->{lmConf} =
|
2008-11-17 17:59:56 +01:00
|
|
|
Lemonldap::NG::Common::Conf->new( $self->{configStorage} )
|
2008-04-10 11:40:16 +02:00
|
|
|
unless $self->{lmConf};
|
|
|
|
return 0 unless ( ref( $self->{lmConf} ) );
|
|
|
|
$tmp = $self->{lmConf}->getConf;
|
|
|
|
return 0 unless $tmp;
|
2008-04-10 11:34:21 +02:00
|
|
|
}
|
2008-04-10 11:40:16 +02:00
|
|
|
|
2007-02-28 23:36:19 +01:00
|
|
|
# Local configuration prepends global
|
|
|
|
$self->{$_} = $args{$_} || $tmp->{$_} foreach ( keys %$tmp );
|
2006-12-19 21:55:23 +01:00
|
|
|
1;
|
2006-12-18 12:32:33 +01:00
|
|
|
}
|
|
|
|
|
2008-12-28 09:36:52 +01:00
|
|
|
## @method list getProtectedSites()
|
2008-12-26 18:58:48 +01:00
|
|
|
# @return list list of protected virtual hosts.
|
2008-04-10 11:34:21 +02:00
|
|
|
|
2007-10-27 08:02:02 +02:00
|
|
|
# With SharedConf, $locationRules contains a hash table with virtual hosts as
|
|
|
|
# keys. So we can use it to know all protected virtual hosts.
|
|
|
|
sub getProtectedSites {
|
|
|
|
my $self = shift;
|
|
|
|
my @tab = ();
|
|
|
|
return ( keys %{ $self->{locationRules} } )
|
|
|
|
if ( ref $self->{locationRules} );
|
|
|
|
return ();
|
|
|
|
}
|
|
|
|
|
2006-12-18 12:32:33 +01:00
|
|
|
1;
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
Lemonldap::NG::Portal::SharedConf - Module for building Lemonldap::NG
|
|
|
|
compatible portals using a central configuration database.
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2006-12-24 09:37:27 +01:00
|
|
|
use Lemonldap::NG::Portal::SharedConf;
|
|
|
|
my $portal = new Lemonldap::NG::Portal::SharedConf( {
|
|
|
|
configStorage => {
|
|
|
|
type => 'DBI',
|
|
|
|
dbiChain => "dbi:mysql:...",
|
|
|
|
dbiUser => "lemonldap",
|
|
|
|
dbiPassword => "password",
|
|
|
|
dbiTable => "lmConfig",
|
|
|
|
},
|
2008-12-07 21:07:52 +01:00
|
|
|
# Activate SOAP service
|
|
|
|
Soap => 1
|
2006-12-24 09:37:27 +01:00
|
|
|
} );
|
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.
|
2008-06-06 05:51:39 +02:00
|
|
|
print $portal->header('text/html; charset=utf8'); # DON'T FORGET THIS (see L<CGI(3)>)
|
2006-12-18 12:32:33 +01:00
|
|
|
print "...";
|
|
|
|
|
|
|
|
# or redirect the user to the menu
|
|
|
|
print $portal->redirect( -uri => 'https://portal/menu');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Write here the html form used to authenticate with CGI methods.
|
|
|
|
# $portal->error returns the error message if athentification failed
|
|
|
|
# Warning: by defaut, input names are "user" and "password"
|
2008-06-06 05:51:39 +02:00
|
|
|
print $portal->header('text/html; charset=utf8'); # DON'T FORGET THIS (see L<CGI(3)>)
|
2006-12-18 12:32:33 +01:00
|
|
|
print "...";
|
|
|
|
print '<form method="POST">';
|
|
|
|
# In your form, the following value is required for redirection
|
|
|
|
print '<input type="hidden" name="url" value="'.$portal->param('url').'">';
|
|
|
|
# Next, login and password
|
|
|
|
print 'Login : <input name="user"><br>';
|
|
|
|
print 'Password : <input name="password" type="password" autocomplete="off">';
|
|
|
|
print '<input type="submit" value="go" />';
|
|
|
|
print '</form>';
|
|
|
|
}
|
|
|
|
|
2008-12-07 21:07:52 +01:00
|
|
|
SOAP mode authentication (client) :
|
|
|
|
|
|
|
|
#!/usr/bin/perl -l
|
|
|
|
|
|
|
|
use SOAP::Lite;
|
|
|
|
use Data::Dumper;
|
|
|
|
|
|
|
|
my $soap =
|
|
|
|
SOAP::Lite->proxy('http://auth.example.com/')
|
|
|
|
->uri('urn:/Lemonldap::NG::Portal::SharedConf');
|
|
|
|
my $r = $soap->getCookies( 'user', 'password' );
|
|
|
|
|
|
|
|
# Catch SOAP errors
|
|
|
|
if ( $r->fault ) {
|
|
|
|
print STDERR "SOAP Error: " . $r->fault->{faultstring};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $res = $r->result();
|
|
|
|
|
|
|
|
# If authentication failed, display error
|
|
|
|
if ( $res->{error} ) {
|
|
|
|
print STDERR "Error: " . $soap->error( 'fr', $res->{error} )->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
# print session-ID
|
|
|
|
else {
|
|
|
|
print "Cookie: lemonldap=" . $res->{cookies}->{lemonldap};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-18 12:32:33 +01:00
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
Lemonldap::NG::Portal::SharedConf is the base module for building Lemonldap::NG
|
|
|
|
compatible portals using a central database configuration. You have to use by
|
|
|
|
inheritance.
|
|
|
|
|
2006-12-24 09:37:27 +01:00
|
|
|
See L<Lemonldap::NG::Portal::SharedConf> for a complete example.
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
=head1 METHODS
|
|
|
|
|
|
|
|
Same as L<Lemonldap::NG::Portal::Simple>, but Lemonldap::NG::Portal::SharedConf
|
|
|
|
adds a new sub:
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item * scanexpr: used by setGroups to read combined LDAP and Perl expressions.
|
|
|
|
See L<Lemonldap::NG::Portal> for more.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head3 Args
|
|
|
|
|
|
|
|
Lemonldap::NG::Portal::SharedConf use the same arguments than
|
|
|
|
L<Lemonldap::NG::Portal::Simple>, but you can set them either using local
|
|
|
|
variables passed to C<new()> or using variables issued from the database.
|
|
|
|
|
|
|
|
=head2 EXPORT
|
|
|
|
|
|
|
|
=head3 Constants
|
|
|
|
|
|
|
|
Same as L<Lemonldap::NG::Portal::Simple>.
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2006-12-24 09:37:27 +01:00
|
|
|
L<Lemonldap::NG::Portal>, L<Lemonldap::NG::Portal::SharedConf>,
|
2007-04-02 21:13:05 +02:00
|
|
|
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Manager>,
|
|
|
|
http://wiki.lemonldap.objectweb.org/xwiki/bin/view/NG/Presentation
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
2007-11-21 15:03:22 +01:00
|
|
|
Xavier Guimard, E<lt>x.guimard@free.frE<gt>,
|
|
|
|
Thomas Chemineau, E<lt>thomas.chemineau@linagora.comE<gt>
|
2006-12-18 12:32:33 +01:00
|
|
|
|
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>
|
|
|
|
|
2006-12-18 12:32:33 +01:00
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
|
2007-11-21 15:03:22 +01:00
|
|
|
Copyright (C) 2005-2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt> and
|
|
|
|
Thomas Chemineau, E<lt>thomas.chemineau@linagora.comE<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
|