2008-12-03 14:27:30 +01:00
|
|
|
## @file
|
|
|
|
# Main portal for Lemonldap::NG portal
|
|
|
|
|
|
|
|
## @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);
|
2009-12-11 22:17:06 +01:00
|
|
|
use Lemonldap::NG::Common::Conf; #link protected lmConf Configuration
|
2009-12-02 16:08:35 +01:00
|
|
|
use Lemonldap::NG::Common::Conf::Constants; #inherits
|
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;
|
|
|
|
|
2009-11-30 17:46:14 +01:00
|
|
|
our $VERSION = '0.70';
|
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
|
|
|
##################
|
|
|
|
|
2009-02-17 15:56:38 +01:00
|
|
|
## @method protected 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 = @_;
|
|
|
|
}
|
2009-11-30 17:46:14 +01:00
|
|
|
|
2007-02-28 23:36:19 +01:00
|
|
|
%$self = ( %$self, %args );
|
2008-04-10 11:40:16 +02:00
|
|
|
|
2009-11-30 17:46:14 +01:00
|
|
|
# Get global configuration
|
|
|
|
my $globalconf = $self->_getLmConf;
|
2009-12-11 22:17:06 +01:00
|
|
|
return 0 unless $globalconf;
|
2009-11-30 17:46:14 +01:00
|
|
|
|
|
|
|
# Get local configuration
|
|
|
|
my $localconf = $self->_getLocalLmConf;
|
|
|
|
|
|
|
|
# Configuration load order:
|
|
|
|
# 1/ Global configuration
|
|
|
|
# 2/ Local file configuration
|
|
|
|
# 3/ Script embedded configuration
|
|
|
|
$self->{$_} = $args{$_} || $globalconf->{$_} foreach ( keys %$globalconf );
|
2009-12-11 22:17:06 +01:00
|
|
|
if ($localconf) {
|
|
|
|
$self->{$_} = $args{$_} || $localconf->{$_}
|
|
|
|
foreach ( keys %$localconf );
|
2009-12-04 10:44:37 +01:00
|
|
|
}
|
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()
|
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.
|
2009-02-25 19:10:07 +01:00
|
|
|
# @return list list of protected virtual hosts.
|
2007-10-27 08:02:02 +02:00
|
|
|
sub getProtectedSites {
|
|
|
|
my $self = shift;
|
|
|
|
my @tab = ();
|
|
|
|
return ( keys %{ $self->{locationRules} } )
|
|
|
|
if ( ref $self->{locationRules} );
|
|
|
|
return ();
|
|
|
|
}
|
|
|
|
|
2009-02-25 19:10:07 +01:00
|
|
|
## @method private hashref _getLmConf()
|
|
|
|
# Call and return Lemonldap::NG::Common::Conf::getConf() value.
|
|
|
|
# @return Lemonldap::NG shared configuration
|
2009-02-24 18:53:59 +01:00
|
|
|
sub _getLmConf {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{lmConf} = Lemonldap::NG::Common::Conf->new( $self->{configStorage} )
|
|
|
|
unless $self->{lmConf};
|
|
|
|
return 0 unless ( ref( $self->{lmConf} ) );
|
|
|
|
return $self->{lmConf}->getConf;
|
|
|
|
}
|
|
|
|
|
2009-11-30 17:46:14 +01:00
|
|
|
## @method private hashref _getLocalLmConf()
|
|
|
|
# Call and return Lemonldap::NG::Common::getLocalConf() value
|
|
|
|
# @return Lemonldap::NG local configuration
|
|
|
|
sub _getLocalLmConf {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Get Configuration object
|
|
|
|
unless ( defined $self->{lmConf} ) {
|
|
|
|
return 0 unless $self->_getLmConf();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get local configuration parameters for portal
|
2009-12-11 22:17:06 +01:00
|
|
|
return $self->{lmConf}->getLocalConf(PORTALSECTION);
|
2009-11-30 17:46:14 +01:00
|
|
|
}
|
|
|
|
|
2006-12-18 12:32:33 +01:00
|
|
|
1;
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2010-01-03 09:09:59 +01:00
|
|
|
=encoding utf8
|
|
|
|
|
2006-12-18 12:32:33 +01:00
|
|
|
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/')
|
2009-02-05 18:05:18 +01:00
|
|
|
->uri('urn:/Lemonldap::NG::Common::::CGI::SOAPService');
|
2008-12-07 21:07:52 +01:00
|
|
|
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
|