Clément OUDOT > Lemonldap-NG-Portal-1.2.5 > Lemonldap::NG::Portal

Download:
Lemonldap-NG-Portal-1.2.5.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.2.5   Source   Latest Release: Lemonldap-NG-Portal-1.3.3

NAME ^

Lemonldap::NG::Portal - The authentication portal part of Lemonldap::NG Web-SSO system.

SYNOPSIS ^

  use Lemonldap::NG::Portal::SharedConf;
  my $portal = new Lemonldap::NG::Portal::SharedConf (
         configStorage => {
            type          => 'DBI',
            dbiChain      => "dbi:mysql:database=lmSessions;host=1.2.3.4",
            dbiUser       => "lemon",
            dbiPassword   => "pass",
         },
         # Activate SOAP service
         Soap           => 1
        );


  if($portal->process()) {
      # Write here the menu with CGI methods. This page is displayed ONLY IF
      # the user was not redirected here by a Lemonldap::NG::Handler,
      # else, the process sub redirect the user to the initial requested URI.
      print $portal->header('text/html; charset=utf8'); # DON'T FORGET THIS (see L<CGI(3)>)
      print "...";
  
      # or redirect the user to the menu
      print $portal->redirect( -uri => 'https://portal/menu');
      
      # You can also add a "Logout" link:
      print "<a href=\"$ENV{SCRIPT_NAME}?logout=1\">";
  }
  else {
      # Write here the html form used to authenticate with CGI methods.
      # $portal->error returns the error message if authentication failed
      # You can force the language in error like this :
      #   print $portal->error('fr')
      # Warning: by defaut, input names are "user" and "password"
      print $portal->header('text/html; charset=utf8'); # DON'T FORGET THIS (see L<CGI(3)>)
      print "<html> ...";
      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"><br>';
      print '<input type=submit value="OK">';
      print '</form>';
  }

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::Common::CGI::SOAPService');
  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};
      }
  }

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 portal part inherits from CGI so yo can use it both with Apache 1 and 2 and use all CGI features.

Authentication, Autorization, 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 if all your protected sites use https.

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. The purgeCentralCache provided in example/ directory can help you to do it. By default, a session stay 10 minutes in the Handler local storage, so in the worth case, a user is authorized 10 minutes after he lost his rights.

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:

Example

Exported variables (in Lemonldap::NG::Portal, will be stored in configuration database):

  exportedVars => {
      cn            => "cn",
      departmentUID => "departmentUID",
      login         => "uid",
  },

User groups (stored in configuration database with Lemonldap::NG::Manager):

  groups => {
      group1 => '{ $departmentUID eq "unit1" or $login = "xavier.guimard" }',
      ...
  },

Area protection (stored in configuration database with Lemonldap::NG::Manager):

  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: see examples in Lemonldap::NG::Portal distribution) both in groups evaluations and area protections (you just have to call them with a "$").

You have to be careful when choosing your expressions:

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 in groups parameter, or Perl expression or mixed expressions. Perl expressions has to be enclosed with {}:

It is also recommended to use Perl expressions to avoid requiering 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 User-Auth field is used but you can change it using the exportedHeaders parameters (stored in the configuration database). This parameters contains an associative array:

Example:

  exportedHeaders => {
      www1.domain.com => {
          'Auth-User' => '$uid',
          'Unit'      => '$ou',
      },
      www2.domain.com => {
          'Authorization' => '"Basic ".encode_base64($employeeNumber.":dummy")',
      },
  }

Storage systems

Lemonldap::NG use 3 levels of cache for authenticated users:

So the number of request to the central storage is limited to 1 per 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 (See Synopsis) and/or by configuring Handler to intercept some URL directly in the manager interface and/or in Apache configuration file (See Lemonldap::NG::Handler). The logout system:

Existing sessions

By default, when a user tries to connect to the portal with a valid cookie, the portal proposes a new authentication. This behaviour can be change easily by changing existingSession sub :

  use Lemonldap::NG::Portal::SharedConf qw(:all);
  
  my $portal = Lemonldap::NG::Portal::SharedConf->new ( {
                existingSession => sub {PE_DONE},
                configStorage => ...
                ...
  });

PORTAL OPTIONS ^

Manager options

All options here can be set both in the manager interface and in the constructor ($portal->new()). Local arguments have the precedence on arguments set by the manager.

Local options

Those options can not be set using the manager but have to be passed to the constructor (new()).

CAS authentication options :

Liberty-Alliance authentication options :

SSL authentication options :

USING LEMONLDAP::NG::PORTAL FOR DEVELOPMENT ^

Lemonldap::NG::Portal provides different modules:

SEE ALSO ^

Lemonldap::NG::Portal::SharedConf, Lemonldap::NG::Portal::Simple Lemonldap::NG::Handler, 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: http://jira.ow2.org

DOWNLOAD ^

Lemonldap::NG is available at http://forge.objectweb.org/project/showfiles.php?group_id=274

COPYRIGHT AND LICENSE ^

Copyright (C) 2006, 2007, 2008, 2009, 2010 by Xavier Guimard, <x.guimard@free.fr>
Copyright (C) 2012 by Fran�ois-Xavier Deltombe, <fxdeltombe@gmail.com.>
Copyright (C) 2006, 2010, 2011, 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/.

syntax highlighting: