Provided by: liblemonldap-ng-handler-perl_1.9.16-2_all
NAME
Lemonldap::NG::Handler - The Apache protection module part of Lemonldap::NG Web-SSO system.
SYNOPSIS
Configure Apache Call Handler in /apache-dir/conf/httpd.conf: # Load your package PerlRequire /My/File # TOTAL PROTECTION PerlHeaderParserHandler Lemonldap::NG::Handler::DefaultHandler # OR SELECTED AREA <Location /protected-area> PerlHeaderParserHandler Lemonldap::NG::Handler::DefaultHandler </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 Lemonldap::NG::Handler::DefaultHandler->refresh </Location> To display the status page, add something like this : <Location /status> Order deny,allow Allow from 10.1.1.0/24 Deny from all PerlHeaderParserHandler Lemonldap::NG::Handler::DefaultHandler->status </Location>
DESCRIPTION
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. The Apache module part works both with Apache 1.3.x and 2.x ie mod_perl 1 and 2 but not with mod_perl 1.99. Authentication, Authorization, Accounting Authentication If a user isn't authenticated and attempts 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 for more). Lemonldap::NG use session cookies generated by Apache::Session so as secure as a 128-bit random cookie. You may use the "securedCookie" options of Lemonldap::NG::Portal to avoid session hijacking. You have to manage life of sessions by yourself since Lemonldap::NG knows nothing about the 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. Authorization Authorization is controlled 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 (see "exportedHeaders" parameter in Lemonldap::NG::Portal documentation). • 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 to see how configuration is stored) Exported variables (values will be stored in session database by Lemonldap::NG::Portal): exportedVars => { cn => "cn", departmentUID => "departmentUID", login => "uid", }, User groups (values will be stored in session database by Lemonldap::NG::Portal): groups => { group1 => '{ $departmentUID eq "unit1" or $login = "xavier.guimard" }', ... }, Area protection: locationRules => { www1.domain.com => { '^/protected/.*$' => '$groups =~ /\bgroup1\b/', default => 'accept', }, www2.domain.com => { '^/site/.*$' => '$uid eq "xavier.guimard" or $groups =~ /\bgroup2\b/', '^/(js|css)' => 'accept', default => 'deny', }, }, 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. See Lemonldap::NG::Manager) 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, • "locationRules" and "exportedheaders" are evaluated for each request on a protected area. It is also recommended to use the "groups" mechanism to avoid having to evaluate a long expression at each HTTP request: locationRules => { www1.domain.com => { '^/protected/.*$' => '$groups =~ /\bgroup1\b/', }, }, You can also use LDAP filters, or Perl expression or mixed expressions in "groups" parameter. 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 recommended to use Perl expressions to avoid requiring the LDAP server more than 2 times per authentication. Accounting Logging portal access Lemonldap::NG::Portal doesn't log anything by default, but it's easy to overload "log" method for normal portal access or using "error" method to know what was wrong if "process" method has failed. Logging application access Because an handler knows nothing about the protected application, it can't do more than logging URL. As Apache does this fine, Lemonldap::NG::Handler gives it the name to used in logs. The "whatToTrace" parameters 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 (stored in the configuration database). This parameters contains an associative array per virtual host: • keys are the names of the chosen headers • values are Perl expressions where you can use user datas stored in the global store by calling them "$<varname>". Example: exportedHeaders => { www1.domain.com => { 'Auth-User' => '$uid', 'Unit' => '$ou', }, www2.domain.com => { 'Authorization' => '"Basic ".encode_base64($employeeNumber.":dummy", "")', 'Remote-IP' => '$ip', }, } Session storage systems Lemonldap::NG use 3 levels of cache for authenticated users: • an Apache::Session::* module choosed with the "globalStorage" parameter (completed with "globalStorageOptions") and used by lemonldap::NG::Portal to store authenticated user parameters, • a Cache::Cache module choosed with the "localSessionStorage" parameter (completed with "localSessionStorageOptions") and used to share authenticated users between Apache's threads or processus and of course between virtual hosts, • 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. Logout system Lemonldap::NG provides a single logout system: you can use it by adding a link to the portal with "logout=1" parameter in the portal (See Lemonldap::NG::Portal) and/or by configuring handler to intercept some URL (See Sinopsys). The logout system: • delete session in the global session storage, • replace Lemonldap::NG cookie by '', • delete handler caches only if logout action was started from a protected application and only in the current Apache server. So in other servers, session is still in cache for 10 minutes maximum if the user was connected on it in the last 10 minutes. You can also configure rules in the Manager interface to intercept logout URL. See Lemonldap::NG::Manager and Lemonldap::NG::Handler for more.
USING LEMONLDAP::NG::HANDLER FOR DEVELOPMENT
Lemonldap::NG::Handler provides different modules: • Lemonldap::NG::Handler::CGI: if you have only a few Perl CGI to protect, you can use this module in your CGI instead of protecting it under Lemonldap::NG::Handler::SharedConf. • Lemonldap::NG::Handler::Proxy: this module isn't used to manage security but is written to create a reverse-proxy without using mod_proxy. In some case, mod_proxy does not manage correctly some redirections, that is why this module still exists. All those modules are compatible both with Apache and mod_perl version 1 and 2, but NOT with mod_perl 1.99. If you use Linux distributions like Debian Sarge who provide mod_perl 1.99 for Apache2, you have to use Apache-1.3 or to download a mod_perl2 backport.
SEE ALSO
Lemonldap::NG::Handler::DefaultHandler, Lemonldap::NG::Portal, Lemonldap::NG::Manager, <http://lemonldap-ng.org/>
AUTHOR
Clement Oudot, <clem.oudot@gmail.com> François-Xavier Deltombe, <fxdeltombe@gmail.com.> Xavier Guimard, <x.guimard@free.fr>
BUG REPORT
Use OW2 system to report bug or ask for features: <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
DOWNLOAD
Lemonldap::NG is available at <http://forge.objectweb.org/project/showfiles.php?group_id=274>
COPYRIGHT AND LICENSE
Copyright (C) 2005-2012 by Xavier Guimard, <x.guimard@free.fr> Copyright (C) 2012-2015 by François-Xavier Deltombe, <fxdeltombe@gmail.com.> Copyright (C) 2006-2012 by Clement Oudot, <clem.oudot@gmail.com> This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.