PEAR::LiveUser - Integrating into new and existing applications

Arnaud Limbourg

what is LiveUser ?

multiple backends, easy to customize

Rights Managements

  • Rights grouping
    • Applications
    • Areas
  • Rights assignments
    • User rights
    • Group rights
    • Areas administrators

Rights Complexity management

  • Simple
    • users
    • user rights
  • Medium = simple +
    • groups
    • groups right
  • Complex = medium +
    • subgroups
    • implied rights
    • rights level

Integration in a new application

  • Requirements
  • Simple example
    • Authentication
    • File based
  • A more complex example
    • Authentication and permissions
    • Database backend

Simple example

$liveuserConfig = array(
    'authContainers'    => array(0 => array(
            'type' => 'XML',
            'file' => 'Auth_XML.xml',
            'loginTimeout' => 0,
            'expireTime'   => 3600,
            'idleTime'     => 1800,
            'allowDuplicateHandles'  => false,
            'passwordEncryptionMode' => 'MD5'
        )
    )
);

require_once 'LiveUser.php';

$liveuser = LiveUser::singleton($liveuserConfig);

if (is_array($liveuser)) {
     echo 'It was impossible to initiate the object. The following errors occured';
     var_export($liveuser);
     exit();
} elseif (!$liveuser) {
    die('An unknown error occurred');
}

$liveuser->init();
  

Complex example

Data Administration

Administration (the future)

function getUsers($fields, $filters, $order, $rekey, $limit, $offset)
{
  // base table on which to execute the query
  $select_tables = array('users');

  // entity tables allowed to be included in the join 
  // (not including tables that simply model the relation
  // (like groupUsers) which are defined in the relevant
  // tables definition as possible join paths
  $tables = array('users', 'groups');

  // $this->backend is one of: DB, MDB, MDB2, XML etc
  $sql =& new LiveUser_SQL($this->_storage);

  // set limit
  $sql->setLimit($limit, $offset);

  // determines which tables need to be joined, which
  // columns to fetch and contructs the where statement
  $sql->generateSelect($select_tables, $tables, $fields, $filters, $order);

  // executes the query, and fetches the result array and
  // rekey's the first column to the first array dimension if needed
  return $sql->executeSelect($rekey);
} 

Where We Are Now

Where We Are Going

  • Reworking the internals (developers)
    • container structure
    • login handling
    • observers
  • User visible changes
    • configuration parameters
    • new native containers: LDAP

Observers have

  • - 'onLogin', triggered if a user has just successfully logged in
  • - 'forceLogin', triggered as replacement for login function
  • - 'onLogout', triggered as replacement for logout function
  • - 'postLogout', triggered as replacement for optional logout redirect
  • - 'onIdled', triggered if maximum idle time is reached
  • - 'onExpired', triggered if authentication session is expired

The new structure

Go further

Questions ?

Thank you !