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;
|
|
|
|
|
2011-12-05 15:21:24 +01:00
|
|
|
our $VERSION = '1.2.0';
|
2008-12-03 14:27:30 +01:00
|
|
|
use base qw(Lemonldap::NG::Portal::Simple);
|
2010-09-19 11:25:47 +02:00
|
|
|
our $confCached;
|
2006-12-18 12:32:33 +01:00
|
|
|
|
2010-10-30 21:25:38 +02:00
|
|
|
BEGIN {
|
|
|
|
eval {
|
|
|
|
require threads::shared;
|
|
|
|
threads::shared::share($confCached);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-09-19 11:25:47 +02:00
|
|
|
my $num = $self->__lmConf->lastCfg;
|
2011-02-03 15:49:12 +01:00
|
|
|
|
2011-12-05 15:21:24 +01:00
|
|
|
# Reload configuration
|
2010-09-19 11:25:47 +02:00
|
|
|
unless ( $confCached and $confCached->{cfgNum} == $num ) {
|
2011-12-05 15:21:24 +01:00
|
|
|
$self->lmLog( "Cached configuration too old, get configuration $num",
|
|
|
|
'debug' );
|
2011-07-07 17:08:45 +02:00
|
|
|
my $gConf = $self->__lmConf->getConf( { cfgNum => $num } );
|
|
|
|
my $lConf = $self->__lmConf->getLocalConf(PORTALSECTION);
|
|
|
|
unless ( ref($gConf) and ref($lConf) ) {
|
|
|
|
$self->abort( "Cannot get configuration",
|
|
|
|
$Lemonldap::NG::Common::Conf::msg );
|
|
|
|
}
|
|
|
|
%$confCached = ( %$gConf, %$lConf );
|
2009-12-04 10:44:37 +01:00
|
|
|
}
|
2011-02-03 15:49:12 +01:00
|
|
|
|
2010-09-19 11:47:38 +02:00
|
|
|
%$self = ( %$self, %$confCached, %args, );
|
2011-02-03 15:49:12 +01:00
|
|
|
|
2011-06-30 16:10:56 +02:00
|
|
|
# localStorage should be declared in configuration object
|
|
|
|
# See Handler::SharedConf
|
|
|
|
foreach (qw(localStorage localStorageOptions)) {
|
|
|
|
$self->{$_} ||= $self->__lmConf->{$_};
|
|
|
|
}
|
|
|
|
|
2011-02-03 15:49:12 +01:00
|
|
|
$self->lmLog( "Now using configuration: " . $confCached->{cfgNum},
|
|
|
|
'debug' );
|
|
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
2010-09-19 11:25:47 +02:00
|
|
|
sub __lmConf {
|
2009-02-24 18:53:59 +01:00
|
|
|
my $self = shift;
|
2010-09-19 11:25:47 +02:00
|
|
|
return $self->{lmConf} if ( $self->{lmConf} );
|
|
|
|
my $r = Lemonldap::NG::Common::Conf->new( $self->{configStorage} );
|
|
|
|
$self->abort(
|
|
|
|
"Cannot create configuration object",
|
|
|
|
$Lemonldap::NG::Common::Conf::msg
|
|
|
|
) unless ( ref($r) );
|
|
|
|
$self->{lmConf} = $r;
|
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} ) {
|
2012-02-15 12:58:32 +01:00
|
|
|
print STDERR "Error: " . $soap->error( $res->{error} )->result();
|
2008-12-07 21:07:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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>,
|
2010-10-26 08:08:16 +02:00
|
|
|
L<http://lemonldap-ng.org/>
|
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:
|
2010-10-26 08:08:16 +02:00
|
|
|
L<http://jira.ow2.org>
|
2007-04-14 15:12:11 +02:00
|
|
|
|
|
|
|
=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
|
|
|
|
|
2010-10-23 10:35:38 +02:00
|
|
|
Copyright (C) 2005, 2007, 2010 by Xavier Guimard E<lt>x.guimard@free.frE<gt> and
|
2007-11-21 15:03:22 +01:00
|
|
|
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
|
2010-10-24 09:25:44 +02:00
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.0 or,
|
2006-12-18 12:32:33 +01:00
|
|
|
at your option, any later version of Perl 5 you may have available.
|
|
|
|
|
|
|
|
=cut
|