Commit 1b1b7d85 authored by Xavier Guimard's avatar Xavier Guimard

* New feature: configurtion access via SOAP

git-svn-id: svn://svn.forge.objectweb.org/svnroot/lemonldap/trunk@47 1dbb9719-a921-0410-b57f-c3a383c2c641
parent d329d752
use 5.006000;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
......@@ -9,11 +8,8 @@ WriteMakefile(
'Apache::Session' => 0,
'LWP::UserAgent' => 0,
'Cache::Cache' => 0,
'MIME::Base64' => 0,
'DBI' => 0,
'Exporter' => 0,
'Lemonldap::NG::Manager' => 0.03,
}, # e.g., Module::Name => 1.1
'Lemonldap::NG::Manager' => 0.4,
}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Lemonldap/NG/Handler.pm', # retrieve abstract from module
AUTHOR => 'Xavier Guimard <x.guimard@free.fr>') : ()),
......
Lemonldap-NG-Handler version 0.01
==============================
Lemonldap-NG
====================
INSTALLATION
Lemonldap::NG is a modular Web-SSO based on Apache::Session modules. It
simplifies the build of a protected area with a few changes in the application.
It manages both authentication and authorization and provides headers for
accounting. So you can have a full AAA protection for your web space as
described below.
1 - Installation
2 - Authentication, Authorization and Accounting mechanisms
2.1 - Authentication
2.2 - Authorization
2.3 - Accounting
3 - Session storage system
4 - Author
5 - Copyright and licence
1 - INSTALLATION
================
Lenmonldap::NG is a different project than Lemonldap and contains all you need
to use and administer it. So softwares, like Lemonldap webmin module, may not
work with Lemonldap::NG.
The Apache module part (Lemonldap::NG::Handler) works both with Apache 1.3.x
and 2.x ie mod_perl 1 and 2 (but not with mod_perl 1.99). Portal and Manager
act as CGI, so they can work everywhere.
See INSTALL file in the whole source tree of Leonldap::NG for a complete
installation documentation.
To install this module type the following:
......@@ -10,24 +38,166 @@ To install this module type the following:
make test
make install
DEPENDENCIES
2 - AUTHENTICATION, AUTHORIZATION AND ACCOUNTING MECHANISMS
===========================================================
Warning: Lemonldap::NG configuration has to be edited using the manager unless
you know exactly what you are doing. The parameters discussed here are all in
the configuration tree.
2.1 - Authentication
If a user isn't authenticated and attemps to connect to an area protected by a
Lemonldap::NG compatible handler, he is redirected to a portal. The portal
authenticates user with a ldap bind by default, but you can also use another
authentication sheme like using x509 user certificates (see
Lemonldap::NG::Portal::AuthSSL(3) for more).
Lemonldap use session cookies generated by Apache::Session so as secure as a
128-bit random cookie. You may use the securedCookie options to avoid session
hijacking.
You have to manage life of sessions by yourself since Lemonldap::NG knows
nothing about the L<Apache::Session> module you've choosed, but it's very easy
using a simple cron script because Lemonldap::NG::Portal stores the start
time in the _utime field.
By default, a session stay 10 minutes in the local storage, so in the worth
case, a user is authorized 10 minutes after he lost his rights.
2.2 - Authorization
Authorization is controled only by handlers because the portal knows nothing
about the way the user will choose. When configuring your Web-SSO, you have to:
* choose the ldap attributes you want to use to manage accounting and
authorization.
* create Perl expressions to define user groups (using ldap attributes)
* create an array foreach virtual host associating URI regular expressions and
Perl expressions to use to grant access.
Example (See Lemonldap::NG::Manager::Conf(3) to see how configuration is stored
* Exported variables :
# Custom-Name => LDAP attribute
cn => cn
departmentUID => departmentUID
login => uid
* User groups :
# Custom-Name => group definition
group1 => { $departmentUID eq "unit1" or $login = "xavier.guimard" }
* Area protection:
# Each VirtualHost has its own configuration
# associating URL regexp to Perl expression
* www1.domain.com :
^/protected/.*$ => $groups =~ /\bgroup1\b/
default => accept
},
* www2.domain.com => {
^/site/.*$ => $uid eq "admin" or $groups =~ /\bgroup2\b/
^/(js|css) => accept
default => deny
},
},
2.2.1 - Performance
You can use Perl expressions as complicated as you want and you can use all
the exported LDAP attributes (and create your own attributes: with 'macros'
mechanism) in groups evaluations, area protections or custom HTTP headers
(you just have to call them with a "$").
This module requires these other modules and libraries:
You have to be careful when choosing your expressions:
Apache::Session, LWP::UserAgent, 'Cache::Cache', 'MIME::Base64',
'DBI'
* groups and macros are evaluated each time a user is redirected to the portal
* virtual host rules and exported headers are evaluated for each request on a
protected area.
and of course mod_perl1 or mod_perl2.
It is also recommanded to use the groups mechanism to avoid having to evaluate
a long expression at each HTTP request:
Lemonldap::NG is known to not work with mod_perl 1.99 (used in Debian
Sarge). Use Apache-1.3 instead.
# Virtual hosts :
...
www1.domain.com :
^/protected/.*$ => $groups =~ /\bgroup1\b/
COPYRIGHT AND LICENCE
You can also use LDAP filters, or Perl expression or mixed expressions in
groups definitions. Perl expressions has to be enclosed with {}:
Copyright (C) 2005 by Xavier Guimard
* group1 => (|(uid=xavier.guimard)(ou=unit1))
* group1 => {$uid eq "xavier.guimard" or $ou eq "unit1"}
* group1 => (|(uid=xavier.guimard){$ou eq "unit1"})
It is also recommanded to use Perl expressions to avoid requiering the LDAP
server more than 2 times per authentication.
2.3 - Accounting
2.3.1 - Logging portal access>
Lemonldap::NG::Portal doesn't log anything by default, but it's easy to
overload log method for normal portal access.
2.3.2 - Logging application access
Because a Web-SSO knows nothing about the protected application, it can't do
more than logging URL. As Apache does this fine, L<Lemonldap::NG::Handler>
gives it the name to used in logs. The whatToTrace parameter indicates
which variable Apache has to use ($uid by default).
The real accounting has to be done by the application itself which knows the
result of SQL transaction for example.
Lemonldap::NG can export HTTP headers either using a proxy or protecting
directly the application. By default, the Auth-User field is used but you can
change it using the exportedHeaders parameters (in the Manager, each virtual
host as custom headers branch). This parameters contains an associative array
per virtual host:
* keys are the names of the choosen headers
* values are Perl expressions where you can use user datas stored in the
global storage.
Example:
* www1.domain.com :
Auth-User => $uid
Unit => $ou
* www2.domain.com :
Authorization => "Basic ".encode_base64($employeeNumber.":dummy")
Remote-IP => $ip
3 - SESSION STORAGE SYSTEM
Lemonldap::NG use 3 levels of cache for authenticated users:
* an Apache::Session::* module used by lemonldap::NG::Portal to store
authenticated user parameters,
* a Cache::Cache* module used by Lemonldap::NG::Handler to share authenticated
users between Apache's threads or processus and of course between virtual
hosts on the same machine
* Lemonldap::NG::Handler variables : if the same user use the same thread or
processus a second time, no request are needed to grant or refuse access.
This is very efficient with HTTP/1.1 Keep-Alive system.
So the number of request to the central storage is limited to 1 per active
user each 10 minutes.
Lemonldap::NG is very fast, but you can increase performance using a
Cache::Cache module that does not use disk access.
4 - AUTHOR
Xavier Guimard, x.guimard@free.fr
5 - COPYRIGHT AND LICENSE
Copyright (C) 2005-2007 by Xavier Guimard x.guimard@free.fr
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.
......@@ -46,6 +46,7 @@ example/imgs/tombs_mag.gif
example/lemonldap-ng-manager.js
example/lmConfig.mysql
example/index.pl
example/soapserver.pl
lib/Lemonldap/NG/Manager.pm
lib/Lemonldap/NG/Manager/_HTML.pm
lib/Lemonldap/NG/Manager/_i18n.pm
......@@ -55,6 +56,7 @@ lib/Lemonldap/NG/Manager/Conf/DBI.pm
lib/Lemonldap/NG/Manager/Conf/File.pm
lib/Lemonldap/NG/Manager/Conf/SOAP.pm
lib/Lemonldap/NG/Manager/Help.pm
lib/Lemonldap/NG/Manager/SOAPServer.pm
Makefile.PL
MANIFEST
META.yml Module meta-data (added by MakeMaker)
......
......@@ -5,11 +5,11 @@ WriteMakefile(
NAME => 'Lemonldap::NG::Manager',
VERSION_FROM => 'lib/Lemonldap/NG/Manager.pm', # finds $VERSION
PREREQ_PM => {
DBI => 0,
CGI => 3.08,
Storable => 0,
XML::Simple => 0
}, # e.g., Module::Name => 1.1
'DBI' => 0,
'CGI' => 3.08,
'Storable' => 0,
'XML::Simple' => 0
}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Lemonldap/NG/Manager.pm', # retrieve abstract from module
AUTHOR => 'Xavier Guimard <x.guimard@free.fr>') : ()),
......
Lemonldap-NG-Manager version 0.01
=================================
Lemonldap::NG
=============
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.
Lemonldap::NG is a modular Web-SSO based on Apache::Session modules. It
simplifies the build of a protected area with a few changes in the application.
A README file is required for CPAN modules since CPAN extracts the
README file from a module distribution so that people browsing the
archive can use it get an idea of the modules uses. It is usually a
good idea to provide version information here so that people can
decide whether fixes for the module are worth downloading.
It manages both authentication and authorization and provides headers for
accounting. So you can have a full AAA protection for your web space as
described below.
INSTALLATION
1 - Installation
2 - Authentication, Authorization and Accounting mechanisms
2.1 - Authentication
2.2 - Authorization
2.3 - Accounting
3 - Session storage system
4 - Author
5 - Copyright and licence
1 - INSTALLATION
================
Lenmonldap::NG is a different project than Lemonldap and contains all you need
to use and administer it. So softwares, like Lemonldap webmin module, may not
work with Lemonldap::NG.
The Apache module part (Lemonldap::NG::Handler) works both with Apache 1.3.x
and 2.x ie mod_perl 1 and 2 (but not with mod_perl 1.99). Portal and Manager
act as CGI, so they can work everywhere.
See INSTALL file in the whole source tree of Leonldap::NG for a complete
installation documentation.
To install this module type the following:
......@@ -21,20 +38,169 @@ To install this module type the following:
make test
make install
DEPENDENCIES
2 - AUTHENTICATION, AUTHORIZATION AND ACCOUNTING MECHANISMS
===========================================================
This module requires these other modules and libraries:
Warning: Lemonldap::NG configuration has to be edited using the manager unless
you know exactly what you are doing. The parameters discussed here are all in
the configuration tree.
blah blah blah
2.1 - Authentication
COPYRIGHT AND LICENCE
If a user isn't authenticated and attemps to connect to an area protected by a
Lemonldap::NG compatible handler, he is redirected to a portal. The portal
authenticates user with a ldap bind by default, but you can also use another
authentication sheme like using x509 user certificates (see
Lemonldap::NG::Portal::AuthSSL(3) for more).
Put the correct copyright and licence information here.
Lemonldap use session cookies generated by Apache::Session so as secure as a
128-bit random cookie. You may use the securedCookie options to avoid session
hijacking.
Copyright (C) 2006 by Najette
You have to manage life of sessions by yourself since Lemonldap::NG knows
nothing about the L<Apache::Session> module you've choosed, but it's very easy
using a simple cron script because Lemonldap::NG::Portal stores the start
time in the _utime field.
By default, a session stay 10 minutes in the local storage, so in the worth
case, a user is authorized 10 minutes after he lost his rights.
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.8 or,
at your option, any later version of Perl 5 you may have available.
2.2 - Authorization
Authorization is controled only by handlers because the portal knows nothing
about the way the user will choose. When configuring your Web-SSO, you have to:
* choose the ldap attributes you want to use to manage accounting and
authorization.
* create Perl expressions to define user groups (using ldap attributes)
* create an array foreach virtual host associating URI regular expressions and
Perl expressions to use to grant access.
Example (See Lemonldap::NG::Manager::Conf(3) to see how configuration is stored
* Exported variables :
# Custom-Name => LDAP attribute
cn => cn
departmentUID => departmentUID
login => uid
* User groups :
# Custom-Name => group definition
group1 => { $departmentUID eq "unit1" or $login = "xavier.guimard" }
* Area protection:
# Each VirtualHost has its own configuration
# associating URL regexp to Perl expression
* www1.domain.com :
^/protected/.*$ => $groups =~ /\bgroup1\b/
default => accept
},
* www2.domain.com => {
^/site/.*$ => $uid eq "admin" or $groups =~ /\bgroup2\b/
^/(js|css) => accept
default => deny
},
},
2.2.1 - Performance
You can use Perl expressions as complicated as you want and you can use all
the exported LDAP attributes (and create your own attributes: with 'macros'
mechanism) in groups evaluations, area protections or custom HTTP headers
(you just have to call them with a "$").
You have to be careful when choosing your expressions:
* groups and macros are evaluated each time a user is redirected to the portal
* virtual host rules and exported headers are evaluated for each request on a
protected area.
It is also recommanded to use the groups mechanism to avoid having to evaluate
a long expression at each HTTP request:
# Virtual hosts :
...
www1.domain.com :
^/protected/.*$ => $groups =~ /\bgroup1\b/
You can also use LDAP filters, or Perl expression or mixed expressions in
groups definitions. Perl expressions has to be enclosed with {}:
* group1 => (|(uid=xavier.guimard)(ou=unit1))
* group1 => {$uid eq "xavier.guimard" or $ou eq "unit1"}
* group1 => (|(uid=xavier.guimard){$ou eq "unit1"})
It is also recommanded to use Perl expressions to avoid requiering the LDAP
server more than 2 times per authentication.
2.3 - Accounting
2.3.1 - Logging portal access>
Lemonldap::NG::Portal doesn't log anything by default, but it's easy to
overload log method for normal portal access.
2.3.2 - Logging application access
Because a Web-SSO knows nothing about the protected application, it can't do
more than logging URL. As Apache does this fine, L<Lemonldap::NG::Handler>
gives it the name to used in logs. The whatToTrace parameter indicates
which variable Apache has to use ($uid by default).
The real accounting has to be done by the application itself which knows the
result of SQL transaction for example.
Lemonldap::NG can export HTTP headers either using a proxy or protecting
directly the application. By default, the Auth-User field is used but you can
change it using the exportedHeaders parameters (in the Manager, each virtual
host as custom headers branch). This parameters contains an associative array
per virtual host:
* keys are the names of the choosen headers
* values are Perl expressions where you can use user datas stored in the
global storage.
Example:
* www1.domain.com :
Auth-User => $uid
Unit => $ou
* www2.domain.com :
Authorization => "Basic ".encode_base64($employeeNumber.":dummy")
Remote-IP => $ip
3 - SESSION STORAGE SYSTEM
==========================
Lemonldap::NG use 3 levels of cache for authenticated users:
* an Apache::Session::* module used by lemonldap::NG::Portal to store
authenticated user parameters,
* a Cache::Cache* module used by Lemonldap::NG::Handler to share authenticated
users between Apache's threads or processus and of course between virtual
hosts on the same machine
* Lemonldap::NG::Handler variables : if the same user use the same thread or
processus a second time, no request are needed to grant or refuse access.
This is very efficient with HTTP/1.1 Keep-Alive system.
So the number of request to the central storage is limited to 1 per active
user each 10 minutes.
Lemonldap::NG is very fast, but you can increase performance using a
Cache::Cache module that does not use disk access.
4 - AUTHOR
==========
Xavier Guimard, x.guimard@free.fr
5 - COPYRIGHT AND LICENSE
=========================
Copyright (C) 2005-2007 by Xavier Guimard x.guimard@free.fr
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.
......@@ -2,15 +2,16 @@
use Lemonldap::NG::Manager;
my $h=new Lemonldap::NG::Manager(
{
configStorage=>{
type=>'File',
dirName=>"__DIR__/conf/",
},
dhtmlXTreeImageLocation=> "/imgs/",
# jsFile => /path/to/lemonldap-ng-manager.js,
}
) or die "Impossible de dmarrer";
my $h = new Lemonldap::NG::Manager(
{
configStorage => {
type => 'File',
dirName => "__DIR__/conf/",
},
dhtmlXTreeImageLocation => "/imgs/",
# jsFile => /path/to/lemonldap-ng-manager.js,
}
) or die "Unable to start";
$h->doall();
#!/usr/bin/perl
use Lemonldap::NG::Manager::SOAPServer;
Lemonldap::NG::Manager::SOAPServer->start(
configStorage => {
type => "File",
dirName => "/usr/share/doc/lemonldap-ng/examples/conf/"
}
);
__END__
......@@ -77,6 +77,8 @@ sub getConf {
return $conf;
}
# TODO: SOAP authentication documentation
1;
__END__
......@@ -98,9 +100,9 @@ Web-SSO configuration.
=head1 DESCRIPTION
Lemonldap::NG::Manager provides a simple interface to access to Lemonldap::NG
Web-SSO configuration. It is used by L<Lemonldap::NG::Handler>,
L<Lemonldap::NG::Portal> and L<Lemonldap::NG::Manager>
Lemonldap::NG::Manager::Conf provides a simple interface to access to
Lemonldap::NG Web-SSO configuration. It is used by L<Lemonldap::NG::Handler>,
L<Lemonldap::NG::Portal> and L<Lemonldap::NG::Manager>.
=head2 SUBROUTINES
......@@ -128,6 +130,17 @@ choosen type. Examples:
dbiTable => 'lmConfig',
});
=item * B<SOAP>:
$confAccess = new Lemonldap::NG::Manager::Conf(
{
type => 'SOAP',
proxy => 'https://manager.example.com/soapmanager.pl',
proxyOptions => {
timeout => 5,
},
});
=back
=item * B<getConf>: returns a hash reference to the configuration. it takes
......@@ -150,7 +163,7 @@ getConf returns all (C<select * from lmConfig>).
=head1 SEE ALSO
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Portal>, L<CGI>
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Portal>
=head1 AUTHOR
......
......@@ -7,7 +7,7 @@ our $VERSION = 0.1;
sub prereq {
my $self = shift;
unless ( $self->{proxy} and $self->{uri} ) {
unless ( $self->{proxy} ) {
print STDERR 'No SOAP parameters found (proxy and uri)';
return 0;
}
......@@ -15,9 +15,14 @@ sub prereq {
}
sub _connect {
my $self = shift;
$self->{service} ||= SOAP::Lite -> uri($self->{uri})
-> proxy($self->{proxy});
my $self = shift;
return $self->{service} if ( $self->{service} );
my @args = ( $self->{proxy} );
if ( $self->{proxyOptions} ) {
push @args, %{ $self->{proxyOptions} };
}
$self->{uri} ||= 'urn:/Lemonldap/NG/Manager/SOAPService';
$self->{service} = SOAP::Lite->uri( $self->{uri} )->proxy(@args);
}
sub _soapCall {
......@@ -25,29 +30,192 @@ sub _soapCall {
my $func = shift;
$self->_connect;
my $conf = $self->{service}->$func(@_)->result;
return @$conf;
return $conf;
}
sub available {
my $self = shift;
return $self->_soapCall('available',@_);
return @{ $self->_soapCall( 'available', @_ ) };
}
sub lastCfg {
my $self = shift;
return $self->_soapCall('lastCfg',@_);
return $self->_soapCall( 'lastCfg', @_ );
}
sub store {
my $self = shift;
return $self->_soapCall('store',@_);
return $self->_soapCall( 'store', @_ );
}
sub load {
my $self = shift;
return $self->_soapCall('load',@_);
return $self->_soapCall( 'load', @_ );
}
1;
__END__
=head1 NAME
Lemonldap::NG::Manager::Conf::SOAP - Perl extension written to access to
Lemonldap::NG Web-SSO configuration via SOAP.
=head1 SYNOPSIS
=head2 Client side
=head3 Area protection (Apache handler)
package My::Package;
use base Lemonldap::NG::Handler::SharedConf;
__PACKAGE__->init ( {
localStorage => "Cache::FileCache",
localStorageOptions => {
'namespace' => 'MyNamespace',
'default_expires_in' => 600,
},
configStorage => {
type => 'SOAP',
proxy => 'http://manager.example.com/soapserver.pl',
},
https => 0,
} );
=head3 Authentication portal
use Lemonldap::NG::Portal::SharedConf;
my $portal = Lemonldap::NG::Portal::SharedConf->new ( {
configStorage => {
type => 'SOAP',
proxy => 'http://localhost/devel/test.pl',
}
});
# Next as usual... See Lemonldap::NG::Portal(3)
if($portal->process()) {
...
=head3 Manager
use Lemonldap::NG::Manager;
my $m=new Lemonldap::NG::Manager(
{
configStorage=>{
type => 'SOAP',
proxy => 'http://localhost/devel/test.pl'
},
dhtmlXTreeImageLocation=> "/imgs/",
}
) or die "Unable to start manager";
$m->doall();
=head2 Server side
See L<Lemonldap::NG::Manager::Conf::SOAP> for documentation on client side.
use Lemonldap::NG::Manager::SOAPServer;
Lemonldap::NG::Manager::SOAPServer->start(
configStorage => {
type=>"File",
dirName=>"/usr/share/doc/lemonldap-ng/examples/conf/"
}
=head1 DESCRIPTION
Lemonldap::NG::Manager::Conf provides a simple interface to access to
Lemonldap::NG Web-SSO configuration. It is used by L<Lemonldap::NG::Handler>,
L<Lemonldap::NG::Portal> and L<Lemonldap::NG::Manager>.
Lemonldap::NG::Manager::Conf::SOAP provides the "SOAP" target used to access
configuration via SOAP.
=head2 SECURITY
As Lemonldap::NG::Manager::Conf::SOAP use SOAP::Lite, you have to see
L<SOAP::Transport> to know arguments that can be passed to C<proxyOptions>.
Example :
=over
=item * HTTP Basic authentication
SOAP::transport can use basic authentication by rewriting
C<>SOAP::Transport::HTTP::Client::get_basic_credentials>:
package My::Package;
use base Lemonldap::NG::Handler::SharedConf;
# AUTHENTICATION
BEGIN {
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return 'username' => 'password';
}