mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +01:00
LSauthMethod_anonymous : Added LSauth method and added feature in LSauth/LSsession to disabled SELF access
This commit is contained in:
parent
9f45b422ae
commit
8dbe9bc4aa
5 changed files with 129 additions and 9 deletions
32
public_html/conf/LSauth/config.LSauthMethod_anonymous.php
Normal file
32
public_html/conf/LSauth/config.LSauthMethod_anonymous.php
Normal 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');
|
||||
|
||||
?>
|
|
@ -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
|
||||
*/
|
||||
|
|
66
public_html/includes/class/class.LSauthMethod_anonymous.php
Normal file
66
public_html/includes/class/class.LSauthMethod_anonymous.php
Normal 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.")
|
||||
);
|
||||
?>
|
|
@ -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,13 +1628,15 @@ class LSsession {
|
|||
$LSaccess[self :: $topDn] = $access;
|
||||
}
|
||||
}
|
||||
foreach($LSaccess as $dn => $access) {
|
||||
$LSaccess[$dn] = array_merge(
|
||||
array(
|
||||
'SELF' => 'My account'
|
||||
),
|
||||
$access
|
||||
);
|
||||
if (LSauth :: displaySelfAccess()) {
|
||||
foreach($LSaccess as $dn => $access) {
|
||||
$LSaccess[$dn] = array_merge(
|
||||
array(
|
||||
'SELF' => 'My account'
|
||||
),
|
||||
$access
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self :: $LSaccess = $LSaccess;
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue