LSauthMethod_anonymous : Added LSauth method and added feature in LSauth/LSsession to disabled SELF access

This commit is contained in:
Benjamin Renard 2010-11-25 12:39:35 +01:00
parent 9f45b422ae
commit 8dbe9bc4aa
5 changed files with 129 additions and 9 deletions

View file

@ -0,0 +1,32 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*
***********************************************************
* Configuration of the Anonymous authentification support *
***********************************************************
*/
// User id used for anonymous connections
define('LSAUTHMETHOD_ANONYMOUS_USER','ls');
?>

View file

@ -36,7 +36,8 @@ class LSauth {
static private $params = array (
'displayLoginForm' => true,
'displayLogoutBtn' => true
'displayLogoutBtn' => true,
'displaySelfAccess' => true
);
function start() {
@ -115,6 +116,24 @@ class LSauth {
return self :: $params['displayLogoutBtn'];
}
/**
* Disable self access
*
* @retval void
**/
public function disableSelfAccess() {
self :: $params['displaySelfAccess'] = false;
}
/**
* Can display or not self access
*
* @retval boolean
**/
public function displaySelfAccess() {
return self :: $params['displaySelfAccess'];
}
/*
* For compatibillity until loginForm is migrated in LSauth
*/

View file

@ -0,0 +1,66 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Anonymous authentication provider for LSauth
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSauthMethod_anonymous extends LSauthMethod {
function LSauthMethod_anonymous() {
LSauth :: disableLoginForm();
LSauth :: disableLogoutBtn();
LSauth :: disableSelfAccess();
if (!parent :: LSauthMethod())
return;
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_USER')) || (constant('LSAUTHMETHOD_ANONYMOUS_USER') == "")) {
LSerror :: addErrorCode('LSauthMethod_anonymous_01');
return;
}
return true;
}
/**
* Check Auth Data
*
* Return authentication data or false
*
* @retval Array|false Array of authentication data or False
**/
public function getAuthData() {
$this -> authData = array(
'username' => LSAUTHMETHOD_ANONYMOUS_USER
);
return $this -> authData;
}
}
/*
* Error Codes
*/
LSerror :: defineError('LSauthMethod_anonymous_01',
_("LSauthMethod_anonymous : You must define the LSAUTHMETHOD_ANONYMOUS_USER contant in the configuration file.")
);
?>

View file

@ -1372,6 +1372,7 @@ class LSsession {
$GLOBALS['Smarty'] -> assign('lang_label',_('Language'));
$GLOBALS['Smarty'] -> assign('displayLogoutBtn',LSauth :: displayLogoutBtn());
$GLOBALS['Smarty'] -> assign('displaySelfAccess',LSauth :: displaySelfAccess());
// Infos
if((!empty($_SESSION['LSsession_infos']))&&(is_array($_SESSION['LSsession_infos']))) {
@ -1627,6 +1628,7 @@ class LSsession {
$LSaccess[self :: $topDn] = $access;
}
}
if (LSauth :: displaySelfAccess()) {
foreach($LSaccess as $dn => $access) {
$LSaccess[$dn] = array_merge(
array(
@ -1635,6 +1637,7 @@ class LSsession {
$access
);
}
}
self :: $LSaccess = $LSaccess;
$_SESSION['LSsession']['LSaccess'] = $LSaccess;

View file

@ -45,7 +45,7 @@
</select>
<input type='submit' value='->'/>
</form>
{$connected_as} <span id='user_name'>{$LSsession_username}</span>{if $displayLogoutBtn} <a href='index.php?LSsession_logout'><img src='{$LS_IMAGES_DIR}/logout.png' alt='Logout' title='Logout' /></a>{/if}
{if $displaySelfAccess}{$connected_as} <span id='user_name'>{$LSsession_username}</span>{/if}{if $displayLogoutBtn} <a href='index.php?LSsession_logout'><img src='{$LS_IMAGES_DIR}/logout.png' alt='Logout' title='Logout' /></a>{/if}
</td>
</tr>
<tr>