1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Tidy up alt_auth plugin - mostly documentation, some code rationalisation, conversion to the 2.0 way, etc

This commit is contained in:
e107steved
2011-12-31 17:42:56 +00:00
parent 6f61a7f889
commit e67702099c
21 changed files with 1628 additions and 1245 deletions

View File

@@ -1,4 +1,24 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Common admin/configuration functions for alt_auth plugin
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
@@ -6,6 +26,7 @@
TODO:
1. Header
2. Support array of defaults for table
3. Get rid of all the globals (put into a class?)
*/
if (!defined('e107_INIT')) { exit; }
@@ -24,6 +45,16 @@ if (!is_object($euf))
define('AUTH_UNKNOWN', 4);
define('AUTH_NOT_AVAILABLE', 5);
/**
* Get list of supported authentication methods
* Searches for files *_auth.php in the plugin directory
*
* @param boolean $incE107 - if TRUE, 'e107' is included as an authentication method.
*
* @return array of authentication methods in value fields
*/
function alt_auth_get_authlist($incE107 = TRUE)
{
$authlist = $incE107 ? array('e107') : array();
@@ -40,6 +71,14 @@ function alt_auth_get_authlist($incE107 = TRUE)
}
/**
* Return HTML for selector for authentication method
*
* @param string $name - the name of the selector
* @param string $curval - current value (if any)
* @param string $optlist - comma-separated list of options to be included as choices
*/
function alt_auth_get_dropdown($name, $curval = '', $options = '')
{
$optList = explode(',', $options);
@@ -55,8 +94,12 @@ function alt_auth_get_dropdown($name, $curval = '', $options = '')
}
// All user fields which might, just possibly, be transferred. The array key is the corresponding field in the E107 user database; code prefixes it with 'xf_' to get the parameter
// 'default' may be a single value to set the same for all connect methods, or an array to set different defaults.
/**
* All user fields which might, just possibly, be transferred. The array key is the corresponding field in the E107 user database; code prefixes it
* with 'xf_' to get the parameter
* 'default' may be a single value to set the same for all connect methods, or an array to set different defaults.
*/
$alt_auth_user_fields = array(
'user_email' => array('prompt' => LAN_ALT_12, 'default' => 'user_email', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'mail'),
'user_hideemail' => array('prompt' => LAN_ALT_13, 'default' => 'user_hideemail', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => '', method => 'bool1'),
@@ -68,15 +111,18 @@ $alt_auth_user_fields = array(
'user_sess' => array('prompt' => LAN_ALT_19, 'default' => 'user_sess', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
'user_join' => array('prompt' => LAN_ALT_20, 'default' => 'user_join', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
'user_ban' => array('prompt' => LAN_ALT_21, 'default' => 'user_ban', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
'user_class' => array('prompt' => LAN_ALT_22, 'default' => 'user_class', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
'user_xup' => array('prompt' => LAN_ALT_23, 'default' => 'user_xup', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE)
'user_class' => array('prompt' => LAN_ALT_22, 'default' => 'user_class', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE)
);
// Returns a block of table rows with user DB fields and either checkboxes or entry boxes
// $tableType is the prefix used, without the following underscore
// $frm is the form object to use to create the text
// $parm is the array of options for the current auth type as read from the DB
/**
* Returns a block of table rows with user DB fields and either checkboxes or entry boxes
*
* @param string $tableType is the prefix used, without the following underscore
* @param $frm is the form object to use to create the text
* @param array $parm is the array of options for the current auth type as read from the DB
*/
function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
{
global $alt_auth_user_fields;
@@ -124,7 +170,14 @@ function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
}
// Returns a list of all the user-related fields allowed as an array, whhere the key is the field name
/**
* Returns a list of all the user-related fields allowed as an array, whhere the key is the field name
*
* @param string $tableType is the prefix used, without the following underscore
*
* @return array
*/
function alt_auth_get_allowed_fields($tableType)
{
global $alt_auth_user_fields;
@@ -142,13 +195,19 @@ function alt_auth_get_allowed_fields($tableType)
}
// Routine adds the extended user fields which may be involved into the table of field definitions, so that they're displayed
/**
* Routine adds the extended user fields which may be involved into the table of field definitions, so that they're displayed
*/
function add_extended_fields()
{
global $alt_auth_user_fields, $euf, $pref;
if (!isset($pref['auth_extended'])) return;
if (!$pref['auth_extended']) return;
static $fieldsAdded = FALSE;
if ($fieldsAdded) return;
$xFields = $euf->user_extended_get_fieldList('','user_extended_struct_name');
// print_a($xFields);
@@ -169,6 +228,10 @@ function add_extended_fields()
}
/**
* List of the standard fields which may be displayed for any method.
*/
$common_fields = array(
'server' => array('fieldname' => 'server', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_32, 'help' => ''),
'uname' => array('fieldname' => 'username', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_33, 'help' => ''),
@@ -183,9 +246,21 @@ $common_fields = array(
);
/**
* Return the HTML for all server-related fields required for configuration of a particular method.
* Each is a row of a table having two columns (no <table>...</table> etc added, so can be embedded in a larger table
*
* @param string $prefix is the prefix used, without the following underscore
* @param $frm is the form object to use
* @param array $parm is an array of the current values of each item
* @param string $fields is a list of the fields to display, separated by '|'. The names are the key values from $common_fields table
*
*/
function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pwd|db|table|ufield|pwfield')
{
global $common_fields;
$opts = explode('|',$fields);
$ret = '';
foreach ($common_fields as $fn => $cf)
@@ -204,7 +279,11 @@ function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pw
// Write all the options to the DB. $prefix must NOT have trailing underscore
/**
* Write all the options for a particular authentication type to the DB
*
* @var string $prefix - the prefix string representing the authentication type (currently importdb|e107db|otherdb|ldap|radius). Must NOT have a trailing underscore
*/
function alt_auth_post_options($prefix)
{
global $common_fields, $sql, $admin_log;
@@ -226,13 +305,13 @@ function alt_auth_post_options($prefix)
if (strpos($k,$lprefix) === 0)
{
$v = base64_encode(base64_encode($v));
if($sql -> db_Select("alt_auth", "*", "auth_type='{$prefix}' AND auth_parmname='{$k}' "))
if($sql -> db_Select('alt_auth', '*', "auth_type='{$prefix}' AND auth_parmname='{$k}' "))
{
$sql -> db_Update("alt_auth", "auth_parmval='{$v}' WHERE auth_type='{$prefix}' AND auth_parmname='{$k}' ");
$sql -> db_Update('alt_auth', "auth_parmval='{$v}' WHERE auth_type='{$prefix}' AND auth_parmname='{$k}' ");
}
else
{
$sql -> db_Insert("alt_auth", "'{$prefix}','{$k}','{$v}' ");
$sql -> db_Insert('alt_auth', "'{$prefix}','{$k}','{$v}' ");
}
}
}
@@ -242,11 +321,61 @@ function alt_auth_post_options($prefix)
/**
* Get the HTML for a password type selector.
*
* @param string $name - name to be used for selector
* @param $frm - form object to use
* @param string $currentSelection - current value (if any)
* @param boolean $getExtended - return all supported password types if TRUE, 'core' password types if FALSE
*/
function altAuthGetPasswordSelector($name, $frm, $currentSelection = '', $getExtended = FALSE)
{
$password_methods = ExtendedPasswordHandler::GetPasswordTypes($getExtended);
$text .= $frm->form_select_open($name);
foreach($password_methods as $k => $v)
{
$sel = ($currentSelection == $k) ? " Selected='selected'" : '';
$text .= $frm -> form_option($v, $sel, $k);
}
$text .= $frm->form_select_close();
return $text;
}
// Return test form
/**
* Get configuration parameters for an authentication method
*
* @param string $prefix - the method
*
* @return array
*/
function altAuthGetParams($prefix)
{
$sql = e107::getDB();
$sql->db_Select('alt_auth', '*', "auth_type = '".$prefix."' ");
$parm = array();
while($row = $sql->db_Fetch())
{
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
return $parm;
}
/**
* Return the HTML needed to display the test form.
*
* @param string $prefix - the type of connection being tested
* @param $frm - the form object to use
*
* if $_POST['testauth'] is set, attempts to validate the connection, and displays any returned values
*/
function alt_auth_test_form($prefix, $frm)
{
$text = $frm -> form_open("post", e_SELF, 'testform');
$text = $frm -> form_open('post', e_SELF, 'testform');
$text .= "<table style='width:96%' class='fborder'>
<tr><td colspan='2' class='forumheader2' style='text-align:center;'>".LAN_ALT_42."</td></tr>";

View File

@@ -6,14 +6,30 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Alt_auth plugin - general configuration
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
/*
@todo:
1. Change prefs handling
2. Change admin log references
*/
$eplug_admin = true;
require_once('../../class2.php');
if(!getperms("P") || !plugInstalled('alt_auth'))
if(!getperms('P') || !e107::isInstalled('alt_auth'))
{
header('location:'.e_BASE.'index.php');
exit();
@@ -37,7 +53,7 @@ if(isset($_POST['updateprefs']))
if ($admin_log->logArrayDiffs($temp, $pref, 'AUTH_01'))
{
save_prefs(); // Only save if changes
header("location:".e_SELF);
header('location:'.e_SELF);
exit;
}
}
@@ -91,7 +107,7 @@ else
if(isset($message))
{
$ns -> tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
e107::getRender()->tablerender('', "<div style='text-align:center'><b>".$message."</b></div>");
}
$text = "
@@ -125,9 +141,9 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
<td>".LAN_ALT_6.":<br /></td>
<td>
<select class='tbox' name='auth_noconn'>";
$sel = (!$pref['auth_noconn'] ? "" : " selected = 'selected' ");
$sel = (!$pref['auth_noconn'] ? '' : " selected = 'selected' ");
$text .= "<option value='0' {$sel} >".LAN_ALT_FAIL."</option>";
$sel = ($pref['auth_noconn'] ? " selected = 'selected' " : "");
$sel = ($pref['auth_noconn'] ? " selected = 'selected' " : '');
$text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
</select><div class='smalltext field-help'>".LAN_ALT_7."</div>
</td>
@@ -149,7 +165,7 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
</form>
</div>";
$ns -> tablerender(LAN_ALT_3, $text);
e107::getRender()->tablerender(LAN_ALT_3, $text);
if ($euf->userCount)
@@ -190,13 +206,13 @@ if ($euf->userCount)
</form>
</div>";
$ns -> tablerender(LAN_ALT_60, $text);
e107::getRender()->tablerender(LAN_ALT_60, $text);
}
require_once(e_ADMIN."footer.php");
require_once(e_ADMIN.'footer.php');
function alt_auth_conf_adminmenu()
{

View File

@@ -13,15 +13,26 @@
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('AA_DEBUG',FALSE);
define('AA_DEBUG1',FALSE);
//TODO convert to class constants
//TODO convert to class constants (but may be more useful as globals, perhaps within a general login manager scheme)
define('AUTH_SUCCESS', -1);
define('AUTH_NOUSER', 1);
define('AUTH_BADPASSWORD', 2);
define('AUTH_NOCONNECT', 3);
define('AUTH_UNKNOWN', 4);
define('AUTH_NOT_AVAILABLE', 5);
define('AUTH_NORESOURCE', 6); // Used to indicate, for example, that a required PHP module isn't loaded
class alt_login
{
@@ -30,7 +41,6 @@ class alt_login
public function __construct($method, &$username, &$userpass)
{
global $pref;
$this->e107 = e107::getInstance();
$newvals=array();
@@ -45,7 +55,7 @@ class alt_login
if(isset($_login->Available) && ($_login->Available === FALSE))
{ // Relevant auth method not available (e.g. PHP extension not loaded)
$this->loginResult = AUTH_NOCONNECT;
$this->loginResult = AUTH_NOT_AVAILABLE;
return;
}
@@ -61,7 +71,7 @@ class alt_login
$username = mysql_real_escape_string($username);
}
$username = preg_replace("/\sOR\s|\=|\#/", "", $username);
$username = substr($username, 0, varset($pref['loginname_maxlength'],30));
$username = substr($username, 0, e107::getPref('loginname_maxlength');
$aa_sql = e107::getDb('aa');
$userMethods = new UserHandler;
@@ -157,7 +167,7 @@ class alt_login
if (!isset($db_vals['user_name'])) $db_vals['user_name'] = $username;
if (!isset($db_vals['user_loginname'])) $db_vals['user_loginname'] = $username;
if (!isset($db_vals['user_join'])) $db_vals['user_join'] = time();
$db_vals['user_class'] = varset($pref['initial_user_classes'],'');
$db_vals['user_class'] = e107::getPref('initial_user_classes');
if (!isset($db_vals['user_signature'])) $db_vals['user_signature'] = '';
if (!isset($db_vals['user_prefs'])) $db_vals['user_prefs'] = '';
if (!isset($db_vals['user_perms'])) $db_vals['user_perms'] = '';
@@ -193,17 +203,8 @@ class alt_login
{ // Failure modes
switch($login_result)
{
/*
case AUTH_NOUSER: // Now handled differently
if(!varset($pref['auth_nouser'],0))
{
$username=md5('xx_nouser_xx');
return LOGIN_ABORT;
}
break;
*/
case AUTH_NOCONNECT:
if(varset($pref['auth_noconn'], TRUE))
if(varset(e107::getPref('auth_noconn'), TRUE))
{
$this->loginResult = LOGIN_TRY_OTHER;
return;
@@ -211,9 +212,8 @@ class alt_login
$username=md5('xx_noconn_xx');
$this->loginResult = LOGIN_ABORT;
return;
break;
case AUTH_BADPASSWORD:
if(varset($pref['auth_badpassword'], TRUE))
if(varset(e107::getPref('auth_badpassword'), TRUE))
{
$this->loginResult = LOGIN_TRY_OTHER;
return;
@@ -221,7 +221,6 @@ class alt_login
$userpass=md5('xx_badpassword_xx');
$this->loginResult = LOGIN_ABORT; // Not going to magically be able to log in!
return;
break;
}
}
$this->loginResult = LOGIN_ABORT; // catch-all just in case
@@ -232,7 +231,7 @@ class alt_login
// Function to implement copy methods
public function translate($method, $word)
{
global $tp;
$tp = e107::getParser();
switch ($method)
{
case 'bool1' :

View File

@@ -1,20 +1,25 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e107db_auth.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* e107 DB authorisation for alt_auth plugin
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*
* This connects to a 'foreign' e107 user database to validate the user
*/
/*
@@ -28,36 +33,51 @@
class auth_login
{
var $Available;
var $ErrorText;
var $conf; // Configuration parameters
public $Available = FALSE; // Flag indicates whether DB connection available
public $ErrorText; // e107 error string on exit
private $conf; // Configuration parameters
function auth_login()
/**
* Read configuration, initialise connection to remote e107 database
*
* @return AUTH_xxxx result code
*/
public function __construct()
{
global $sql;
$this->conf = array();
$this->ErrorText = '';
$sql -> db_Select("alt_auth", "*", "auth_type = 'e107db' ");
while($row = $sql -> db_Fetch())
{
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$this->conf = altAuthGetParams('e107db');
$this->Available = TRUE;
}
// Add the reconnect function in here - might be needed
function makeErrorText($extra = '')
/**
* Retrieve and construct error strings
*
* @todo - test whether reconnect to DB is required (shouldn't be)
*/
private function makeErrorText($extra = '')
{
$this->ErrorText = $extra;
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
//global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
//$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
}
function login($uname, $pword, &$newvals, $connect_only = FALSE)
/**
* Validate login credentials
*
* @param string $uname - The user name requesting access
* @param string $pass - Password to use (usually plain text)
* @param pointer &$newvals - pointer to array to accept other data read from database
* @param boolean $connect_only - TRUE to simply connect to the database
*
* @return integer result (AUTH_xxxx)
*
* On a successful login, &$newvals array is filled with the requested data from the server
*/
public function login($uname, $pword, &$newvals, $connect_only = FALSE)
{
//Attempt to open connection to sql database
if(!$res = mysql_connect($this->conf['e107db_server'], $this->conf['e107db_username'], $this->conf['e107db_password']))
@@ -66,6 +86,7 @@ class auth_login
return AUTH_NOCONNECT;
}
//Select correct db
if(!mysql_select_db($this->conf['e107db_database'], $res))
{
mysql_close($res);
@@ -95,7 +116,7 @@ class auth_login
//Get record containing supplied login name
$qry = "SELECT ".implode(',',$sel_fields)." FROM ".$this->conf['e107db_prefix']."user WHERE {$user_field} = '{$uname}' AND `user_ban` = 0";
$qry = 'SELECT '.implode(',',$sel_fields)." FROM ".$this->conf['e107db_prefix']."user WHERE {$user_field} = '{$uname}' AND `user_ban` = 0";
// echo "Query: {$qry}<br />";
if(!$r1 = mysql_query($qry))
{

View File

@@ -1,15 +1,23 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* e107 DB configuration for alt_auth plugin
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
$eplug_admin = true;
require_once('../../class2.php');
@@ -21,65 +29,55 @@ define('ALT_AUTH_ACTION', 'e107db');
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
if($_POST['update'])
{
// $message = update_e107db_prefs();
$message = alt_auth_post_options('e107db');
}
if($message)
{
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
show_e107db_form();
function show_e107db_form()
{
global $sql, $tp, $ns;
$ns = e107::getRender();
$password_methods = ExtendedPasswordHandler::GetPasswordTypes('core');
$sql -> db_Select("alt_auth", "*", "auth_type = 'e107db' ");
$parm = array();
while($row = $sql->db_Fetch())
{
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$parm = altAuthGetParams('e107db');
$frm = new form;
$text = $frm -> form_open("post", e_SELF);
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
$text = $frm -> form_open('post', e_SELF);
$text .= "<table cellpadding='0' cellspacing='0' class='fborder'>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
</colgroup>";
$text .= "<tr><td>".LAN_ALT_26."</td><td>";
$text .= "<tr><td class='forumheader3'>".LAN_ALT_26."</td><td class='forumheader3'>";
$text .= E107DB_LAN_1;
$text .= "</td></tr>";
$text .= alt_auth_get_db_fields('e107db', $frm, $parm, 'server|uname|pwd|db|prefix|classfilt');
$text .= "<tr><td>".E107DB_LAN_9."</td><td>";
$text .= $frm -> form_select_open("e107db_password_method");
foreach($password_methods as $k => $v)
{
$sel = ($parm['e107db_password_method'] == $k) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $k);
}
$text .= $frm -> form_select_close();
$text .= "<tr><td class='forumheader3'>".E107DB_LAN_9."</td><td class='forumheader3'>";
$text .= altAuthGetPasswordSelector('e107db_password_method', $frm, $parm['e107db_password_method'], FALSE);
$text .= "</td></tr>";
$text .= "<tr><td colspan='2'>".E107DB_LAN_11."</td></tr>";
$text .= "<tr><td colspan='2'><br />".E107DB_LAN_11."</td></tr>";
$text .= alt_auth_get_field_list('e107db',$frm, $parm, TRUE);
$text .= "</table><div class='buttons-bar center'>";
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
$text .= "</div>";
$text .= '</div>';
$text .= $frm -> form_close();
$ns->tablerender(E107DB_LAN_10, $text);
@@ -87,7 +85,7 @@ function show_e107db_form()
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('e107db',$frm));
}
require_once(e_ADMIN."footer.php");
require_once(e_ADMIN.'footer.php');

View File

@@ -2,11 +2,11 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Alt_Auth plugin - help
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e_help.php,v $
* $Revision$
@@ -14,6 +14,14 @@
* $Author$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
if (!defined('e107_INIT')) { exit; }
define('ALT_AUTH_PATH', e_PLUGIN.'alt_auth/');

View File

@@ -2,17 +2,25 @@
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Extended password handler for alt_auth plugin
*
* $URL$
* $Id$
*/
/*
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
/**
EXTENDED PASSWORD HANDLER CLASS
- supports many password formats used on other systems
- implements checking of existing passwords only
@@ -23,18 +31,18 @@ To use:
or, optionally:
call CheckPassword(plaintext_password,login_name, stored_value, password_type)
To do:
@todo:
1. Check that public/private declarations of functions are correct
*/
if (!defined('e107_INIT')) { exit; }
require_once(e_HANDLER.'user_handler.php');
// @todo make these class constants
define('PASSWORD_PHPBB_SALT',2);
define('PASSWORD_MAMBO_SALT',3);
define('PASSWORD_JOOMLA_SALT',4);
@@ -50,27 +58,28 @@ require_once(e_HANDLER.'user_handler.php');
define('PASSWORD_WORDPRESS_ID', '$P$'); // WordPress 2.8
class ExtendedPasswordHandler extends UserHandler
{
var $itoa64; // Holds a string of 64 characters for base64 conversion
// var $iteration_count_log2; // Used to compute number of iterations in calculating hash
private $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; // Holds a string of 64 characters for base64 conversion
var $random_state = ''; // A (hopefully) random number
// Constructor
/**
* Constructor - just call parent
*/
function __construct()
{
// Lookup string ready for base64 conversions
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
// Ancestor constructor
parent::__construct();
}
// Return a number of random bytes as specified by $count
function get_random_bytes($count)
/**
* Return a number of random bytes as specified by $count
*/
private function get_random_bytes($count)
{
$this->random_state = md5($this->random_state.microtime().mt_rand(0,10000)); // This will 'auto seed'
@@ -86,10 +95,14 @@ class ExtendedPasswordHandler extends UserHandler
}
// Encode to base64 (each block of three 8-bit chars becomes 4 printable chars)
// Use first $count characters of $input string
function encode64($input, $count)
/**
* Encode to base64 (each block of three 8-bit chars becomes 4 printable chars)
* Use first $count characters of $input string
*/
private function encode64($input, $count)
{
return base64_encode(substr($input, 0, $count)); // @todo - check this works OK
/*
$output = '';
$i = 0;
do
@@ -106,14 +119,17 @@ class ExtendedPasswordHandler extends UserHandler
} while ($i < $count);
return $output;
*/
}
// Method for PHPBB3-style salted passwords, which begin '$H$', and WordPress-style salted passwords, which begin '$P$'
// Given a plaintext password and the complete password/hash function (which includes any salt), calculate hash
// Returns FALSE on error
function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
/**
* Method for PHPBB3-style salted passwords, which begin '$H$', and WordPress-style salted passwords, which begin '$P$'
* Given a plaintext password and the complete password/hash function (which includes any salt), calculate hash
* Returns FALSE on error
*/
private function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
{
$output = '*0';
if (substr($stored_password, 0, 2) == $output)
@@ -173,15 +189,14 @@ class ExtendedPasswordHandler extends UserHandler
}
// Return array of supported password types - key is used internally, text is displayed
function getPasswordTypes($include_core = FALSE)
/**
* Return array of supported password types - key is used internally, text is displayed
*/
public function getPasswordTypes($includeExtended = TRUE)
{
$vals = array();
if ($include_core)
{
$vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
}
if (is_bool($include_core))
if ($includeExtended)
{
$vals = array_merge($vals,array(
'plaintext' => IMPORTDB_LAN_2,
@@ -191,15 +206,17 @@ class ExtendedPasswordHandler extends UserHandler
'sha1' => IMPORTDB_LAN_6,
'phpbb3_salt' => IMPORTDB_LAN_12,
'wordpress_salt' => IMPORTDB_LAN_13,
'wordpress_salt' => IMPORTDB_LAN_14,
'magento_salt' => IMPORTDB_LAN_14,
));
}
return $vals;
}
// Return password type which relates to a specific foreign system
function passwordMapping($ptype)
/**
* Return password type which relates to a specific foreign system
*/
public function passwordMapping($ptype)
{
$maps = array(
'plaintext' => PASSWORD_PLAINTEXT,
@@ -222,8 +239,20 @@ class ExtendedPasswordHandler extends UserHandler
}
// Extension of password validation -
function CheckPassword($pword, $login_name, $stored_hash, $password_type = PASSWORD_DEFAULT_TYPE)
/**
* Extension of password validation to handle more types
*
* @param string $pword - plaintext password as entered by user
* @param string $login_name - string used to log in (could actually be email address)
* @param string $stored_hash - required value for password to match
* @param integer $password_type - constant specifying the type of password to check against
*
* @return PASSWORD_INVALID|PASSWORD_VALID|string
* PASSWORD_INVALID if no match
* PASSWORD_VALID if valid password
* Return a new hash to store if valid password but non-preferred encoding
*/
public function CheckPassword($pword, $login_name, $stored_hash, $password_type = PASSWORD_DEFAULT_TYPE)
{
switch ($password_type)
{
@@ -268,11 +297,11 @@ class ExtendedPasswordHandler extends UserHandler
$pwHash = $salt ? md5($salt.$pword) : md5($pword);
$stored_hash = $hash;
break;
case PASSWORD_E107_SALT :
return e107::getUserSession()->CheckPassword($password, $login_name, $stored_hash);
//return e107::getUserSession()->CheckPassword($password, $login_name, $stored_hash);
return parent::CheckPassword($password, $login_name, $stored_hash);
break;
case PASSWORD_PHPBB_SALT :

View File

@@ -1,20 +1,23 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/importdb_auth.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* imported DB authorisation for alt_auth plugin
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
/*
@@ -26,33 +29,47 @@
AUTH_SUCCESS = valid login
*/
class auth_login
{
var $conf;
var $ErrorText;
public $Available = FALSE; // Flag indicates whether DB connection available
public $ErrorText; // e107 error string on exit
private $conf; // Configuration parameters
function auth_login()
/**
* Read configuration
*
* @return AUTH_xxxx result code
*/
public function __construct()
{
global $sql;
$this->ErrorText = '';
$this->conf = array();
if (!$sql -> db_Select("alt_auth", "*", "auth_type = 'importdb' ")) return AUTH_NOCONNECT; // We should get at least one value
while ($row = $sql -> db_Fetch())
{
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$this->conf = altAuthGetParams('importdb');
$this->Available = TRUE;
}
function makeErrorText($extra = '')
private function makeErrorText($extra = '')
{
$this->ErrorText = $extra;
}
function login($uname, $pword, &$newvals, $connect_only = FALSE)
/**
* Validate login credentials
*
* @param string $uname - The user name requesting access
* @param string $pass - Password to use (usually plain text)
* @param pointer &$newvals - pointer to array to accept other data read from database
* @param boolean $connect_only - TRUE to simply connect to the database
*
* @return integer result (AUTH_xxxx)
*
* On a successful login, &$newvals array is filled with the requested data from the server
*/
public function login($uname, $pword, &$newvals, $connect_only = FALSE)
{
if ($connect_only) return AUTH_SUCCESS; // Big problem if can't connect to our own DB!

View File

@@ -1,25 +1,35 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Alt_auth plugin - 'importdb' configuration
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
$eplug_admin = true;
require_once('../../class2.php');
require_once(e_ADMIN.'auth.php');
require_once(e_HANDLER.'form_handler.php');
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_importdb_conf.php');
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
define("ALT_AUTH_ACTION", "importdb");
require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php");
require_once(e_PLUGIN."alt_auth/extended_password_handler.php");
define('ALT_AUTH_ACTION', 'importdb');
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
if($_POST['update'])
@@ -30,7 +40,7 @@ if($_POST['update'])
if($message)
{
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
e107::getRender()->tablerender("","<div style='text-align:center;'>".$message."</div>");
}
@@ -38,22 +48,13 @@ show_importdb_form();
function show_importdb_form()
{
global $sql, $tp, $ns;
$password_methods = ExtendedPasswordHandler::GetPasswordTypes(FALSE);
$ns = e107::getRender();
// Get the parameters
$sql -> db_Select("alt_auth", "*", "auth_type = 'importdb' ");
$parm = array();
while($row = $sql->db_Fetch())
{
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$parm = altAuthGetParams('importdb');
$frm = new form;
$text = $frm -> form_open("post", e_SELF);
$text = $frm -> form_open('post', e_SELF);
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
<colgroup span='2'>
<col class='col-label' />
@@ -62,23 +63,10 @@ function show_importdb_form()
$text .= "<tr><td colspan='2' class='forumheader3'>".IMPORTDB_LAN_11."</td></tr>";
/* $text .= $frm -> form_select_open("importdb_dbtype");
foreach($db_types as $k => $v)
{
$sel = ($parm['importdb_dbtype'] == $k) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $k);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
*/
$text .= "<tr><td>".IMPORTDB_LAN_9."</td><td>";
$text .= $frm -> form_select_open("importdb_password_method");
foreach($password_methods as $k => $v)
{
$sel = ($parm['importdb_password_method'] == $k) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $k);
}
$text .= $frm -> form_select_close();
$text .= altAuthGetPasswordSelector('importdb_password_method', $frm, $parm['importdb_password_method'], TRUE);
$text .= "</td></tr>";
$text .= "</table><div class='buttons-bar center'>";
@@ -92,31 +80,8 @@ function show_importdb_form()
}
require_once(e_ADMIN."footer.php");
require_once(e_ADMIN.'footer.php');
/*
function update_importdb_prefs()
{
global $sql;
foreach($_POST as $k => $v)
{
$v = base64_encode(base64_encode($v));
if(preg_match("/importdb_/", $k))
{
if($sql -> db_Select("alt_auth", "*", "auth_type='importdb' AND auth_parmname='{$k}' "))
{
$sql -> db_Update("alt_auth", "auth_parmval='{$v}' WHERE auth_type='importdb' AND auth_parmname='{$k}' ");
}
else
{
$sql -> db_Insert("alt_auth", "'importdb','{$k}','{$v}' ");
}
}
}
return "Settings Updated";
}
*/
function importdb_conf_adminmenu()
{

View File

@@ -14,6 +14,14 @@
* $Author$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('LAN_AL_AUTH_01','Alt auth Settings changed');
define('LAN_AL_AUTH_02','Alt auth extended user classes changed');
define('LAN_AL_AUTH_03','Alt auth method settings changed');

View File

@@ -2,7 +2,7 @@
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@@ -12,6 +12,15 @@
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('LAN_ALT_1', 'Primary authorisation type');
define('LAN_ALT_2', 'Update settings');
define('LAN_ALT_3', 'Choose Alternate Authorisation Type');
@@ -35,7 +44,7 @@ define('LAN_ALT_19', 'Photo field');
define('LAN_ALT_20', 'Join date field');
define('LAN_ALT_21', 'Ban status field');
define('LAN_ALT_22', 'Class membership field');
define('LAN_ALT_23', 'XUP file field');
//define('LAN_ALT_23', 'XUP file field');
define('LAN_ALT_24', 'Password salt field');
define('LAN_ALT_25', '(sometimes combined with password for added security)');
define('LAN_ALT_26', 'Database type:');
@@ -95,6 +104,18 @@ define('LAN_ALT_77', 'Only users in this class (on the database set above) are p
define('LAN_ALT_78', 'Failed password action');
define('LAN_ALT_79', 'If user exists in primary DB, but enters an incorrect password, how should that be handled?');
define('IMPORTDB_LAN_2', 'Plain Text');
define('IMPORTDB_LAN_3', 'Joomla salted');
define('IMPORTDB_LAN_4', 'Mambo salted');
define('IMPORTDB_LAN_5', 'SMF (SHA1)');
define('IMPORTDB_LAN_6', 'Generic SHA1');
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
define('IMPORTDB_LAN_8', 'E107 salted (option 2.0 on)');
define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
define('IMPORTDB_LAN_13', 'WordPress salted');
define('IMPORTDB_LAN_14', 'Magento salted');
define('LAN_ALT_FALLBACK', 'Use secondary authorisation');
define('LAN_ALT_FAIL', 'Failed login');

View File

@@ -1,5 +1,27 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Language file
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('E107DB_LAN_1', 'E107 format database');
define('E107DB_LAN_9', 'Password Method:');
define('E107DB_LAN_10', 'Configure E107 db auth');
@@ -7,7 +29,7 @@ define('E107DB_LAN_11', 'Check the box against any field you wish to be transfer
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
define('IMPORTDB_LAN_8', 'E107 salted (option 0.8 on)');
define('IMPORTDB_LAN_8', 'E107 salted (option 2.0 on)');
define('LAN_AUTHENTICATE_HELP','This authentication method is to be used with a second E107 database, which may use a different password format to this system. The

View File

@@ -2,7 +2,7 @@
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@@ -12,22 +12,32 @@
* $Id$
*
*/
define('IMPORTDB_LAN_1', 'Database type');
define('IMPORTDB_LAN_2', 'Plain Text');
define('IMPORTDB_LAN_3', 'Joomla salted');
define('IMPORTDB_LAN_4', 'Mambo salted');
define('IMPORTDB_LAN_5', 'SMF (SHA1)');
define('IMPORTDB_LAN_6', 'Generic SHA1');
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
define('IMPORTDB_LAN_8', 'E107 salted (option 0.8 on)');
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
// Some password-related strings moved to admin_alt_auth.php for generic use
//define('IMPORTDB_LAN_1', 'Database type');
//define('IMPORTDB_LAN_2', 'Plain Text');
//define('IMPORTDB_LAN_3', 'Joomla salted');
//define('IMPORTDB_LAN_4', 'Mambo salted');
//define('IMPORTDB_LAN_5', 'SMF (SHA1)');
//define('IMPORTDB_LAN_6', 'Generic SHA1');
//define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
//define('IMPORTDB_LAN_8', 'E107 salted (option 2.0 on)');
define('IMPORTDB_LAN_9', 'Password Method:');
define('IMPORTDB_LAN_10', 'Configure imported database password type');
define('IMPORTDB_LAN_11', 'This option is to be used when you have imported some other user-based system into E107.
It allows you to accept passwords encoded in the selected non-standard format.
Each user\'s password is converted to E107 format when they log in.');
define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
define('IMPORTDB_LAN_13', 'WordPress salted');
define('IMPORTDB_LAN_14', 'Magento salted');
//define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
//define('IMPORTDB_LAN_13', 'WordPress salted');
//define('IMPORTDB_LAN_14', 'Magento salted');
define('LAN_AUTHENTICATE_HELP','This authentication method is to be used <i>only</i> when you have imported a user database into E107, and the password is in an incompatible format. The

View File

@@ -1,23 +1,44 @@
<?php
define("LDAPLAN_1", "Server address");
define("LDAPLAN_2", "Base DN or Domain<br />LDAP - Enter BaseDN<br />AD - enter the fqdn eg ad.mydomain.co.uk");
define("LDAPLAN_3", "LDAP Browsing user<br />Full context of the user who is able to search the directory.");
define("LDAPLAN_4", "LDAP Browsing password<br />Password for the LDAP Browsing user.");
define("LDAPLAN_5", "LDAP Version");
define("LDAPLAN_6", "Configure LDAP auth");
define("LDAPLAN_7", "eDirectory search filter:");
define("LDAPLAN_8", "This will be used to ensure the username is in the correct tree, <br />ie '(objectclass=inetOrgPerson)'");
define("LDAPLAN_9", "Current search filter will be:");
define("LDAPLAN_10", "Settings Updated");
define("LDAPLAN_11", "WARNING: It appears as if the ldap module is not currently available; setting your auth method to LDAP will probably not work!");
define("LDAPLAN_12", 'Server Type');
define("LDAPLAN_13", 'Update settings');
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* LDAP authorisation for alt_auth plugin - language file
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('LDAPLAN_1', 'Server address');
define('LDAPLAN_2', 'Base DN or Domain<br />LDAP - Enter BaseDN<br />AD - enter the fqdn eg ad.mydomain.co.uk');
define('LDAPLAN_3', 'LDAP Browsing user<br />Full context of the user who is able to search the directory.');
define('LDAPLAN_4', 'LDAP Browsing password<br />Password for the LDAP Browsing user.');
define('LDAPLAN_5', 'LDAP Version');
define('LDAPLAN_6', 'Configure LDAP auth');
define('LDAPLAN_7', 'eDirectory search filter:');
define('LDAPLAN_8', "This will be used to ensure the username is in the correct tree, <br />e.g. '(objectclass=inetOrgPerson)'");
define('LDAPLAN_9', 'Current search filter will be:');
define('LDAPLAN_10', 'Settings Updated');
define('LDAPLAN_11', 'WARNING: It appears that the ldap module is not currently available; setting your auth method to LDAP will probably not work!');
define('LDAPLAN_12', 'Server Type');
define('LDAPLAN_13', 'Update settings');
define('LDAPLAN_14', 'OU for AD (e.g. ou=itdept)');
define('SHOW_COPY_HELP', TRUE);
define('SHOW_CONVERSION_HELP', TRUE);
define('LAN_AUTHENTICATE_HELP','This method can be used to authenticate against most LDAP servers, including Novell\'s eDirectory and Microsoft\'s Active Directory. Refer to the wiki for further information.');
define('LAN_AUTHENTICATE_HELP','This method can be used to authenticate against most LDAP servers, including Novell\'s eDirectory and Microsoft\'s Active Directory. It requires that PHP\'s LDAP extension is loaded. Refer to the wiki for further information.');
?>

View File

@@ -1,14 +1,38 @@
<?php
define("OTHERDB_LAN_1", "Database Type:");
define("OTHERDB_LAN_2", "Server:");
define("OTHERDB_LAN_3", "Username:");
define("OTHERDB_LAN_4", "Password:");
define("OTHERDB_LAN_5", "Database");
define("OTHERDB_LAN_6", "Table");
define("OTHERDB_LAN_7", "Username Field:");
define("OTHERDB_LAN_8", "Password Field:");
define("OTHERDB_LAN_9", "Password Method:");
define("OTHERDB_LAN_10", "Configure otherdb auth");
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Language file
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('OTHERDB_LAN_1', 'Database Type:');
define('OTHERDB_LAN_2', 'Server:');
define('OTHERDB_LAN_3', 'Username:');
define('OTHERDB_LAN_4', 'Password:');
define('OTHERDB_LAN_5', 'Database');
define('OTHERDB_LAN_6', 'Table');
define('OTHERDB_LAN_7', 'Username Field:');
define('OTHERDB_LAN_8', 'Password Field:');
define('OTHERDB_LAN_9', 'Password Method:');
define('OTHERDB_LAN_10', 'Configure otherdb auth');
//define("OTHERDB_LAN_11", "To transfer a field value into the local database, specify the field name in the corresponding box below. Fields marked with
// an asterisk (*) are mandatory.<br />Leave the field blank for it not to be transferred at all");
define('OTHERDB_LAN_12', 'Password Salt Field:');
@@ -16,16 +40,6 @@ define('OTHERDB_LAN_13', '(Leave blank if not used)');
define('OTHERDB_LAN_14', 'Email address Field:');
define('OTHERDB_LAN_15', 'MySQL - generic database');
define("IMPORTDB_LAN_2", 'Plain Text');
define("IMPORTDB_LAN_3", 'Joomla salted');
define("IMPORTDB_LAN_4", 'Mambo salted');
define("IMPORTDB_LAN_5", 'SMF (SHA1)');
define("IMPORTDB_LAN_6", 'Generic SHA1');
define("IMPORTDB_LAN_7", 'MD5 (E107 original)');
define("IMPORTDB_LAN_8", 'E107 salted (option 0.8 on)');
define("IMPORTDB_LAN_12", 'PHPBB2/PHPBB3 salted');
define("IMPORTDB_LAN_14", 'Magento salted');
define('SHOW_COPY_HELP', TRUE);
define('SHOW_CONVERSION_HELP', TRUE);

View File

@@ -1,4 +1,27 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Language file
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
define('LAN_RADIUS_01', 'Server address');
define('LAN_RADIUS_02', 'Shared secret');
define('LAN_RADIUS_03', 'Server user');

View File

@@ -1,47 +1,56 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_auth.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* LDAP authorisation for alt_auth plugin
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
class auth_login
{
var $server;
var $dn;
var $ou;
var $usr;
var $pwd;
var $serverType;
var $ldapErrorCode;
var $ldapErrorText;
var $ErrorText;
var $connection;
var $result;
var $ldapVersion;
var $Available;
var $filter;
var $copyAttribs; // Any attributes which are to be copied on successful login
var $copyMethods;
private $server; // The LDAP server (array of possible servers)
private $dn; // LDAP domain
private $ou; // LDAP OU
private $usr; // User name to log on to server
private $pwd; // Password to log on to server
private $serverType; // Server type = LDAP/AD/eDirectory
public $ldapErrorCode; // LDAP error code on exit
public $ldapErrorText; // LDAP error string on exit
public $ErrorText; // e107 error string on exit
private $connection; // LDAP resource for connection
private $ldapVersion; // Version of LDAP to use
public $Available = FALSE; // Flag indicates whether DB connection available
private $filter; // Filter for eDirectory search
private $copyAttribs; // Any attributes which are to be copied on successful login
private $copyMethods; // Methods which are to be used to copy attributes
function auth_login()
/**
* Read configuration, initialise connection to LDAP database
*
* @return AUTH_xxxx result code
*/
public function auth_login()
{
$this->copyAttribs = array();
$this->copyMethods = array();
$sql = new db;
$sql->db_Select("alt_auth", "*", "auth_type = 'ldap' ");
$sql = e107::getDB('altAuth');
$sql->db_Select('alt_auth', '*', "auth_type = 'ldap' ");
while ($row = $sql->db_Fetch())
{
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
@@ -55,7 +64,7 @@ class auth_login
}
unset($row['auth_parmname']);
}
$this->server = explode(",", $ldap['ldap_server']);
$this->server = explode(',', $ldap['ldap_server']);
$this->serverType = $ldap['ldap_servertype'];
$this->dn = $ldap['ldap_basedn'];
$this->ou = $ldap['ldap_ou'];
@@ -66,24 +75,35 @@ class auth_login
if (!function_exists('ldap_connect'))
{
$this->Available = false;
return false;
return AUTH_NORESOURCE;
}
if (!$this->connect())
{
return AUTH_NOCONNECT;
}
$this->Available = TRUE;
return AUTH_SUCCESS;
}
function makeErrorText($extra = '')
/**
* Retrieve and construct error strings
*/
private function makeErrorText($extra = '')
{
$this->ldapErrorCode = ldap_errno($this->connection);
$this->ldapErrorText = ldap_error($this->connection);
$this->ErrorText = $extra . ' ' . $this->ldapErrorCode . ': ' . $this->ldapErrorText;
}
function connect()
/**
* Connect to the LDAP server
*
* @return boolean TRUE for success, FALSE for failure
*/
public function connect()
{
foreach ($this->server as $key => $host)
{
@@ -104,7 +124,11 @@ class auth_login
return false;
}
function close()
/**
* Close the connection to the LDAP server
*/
public function close()
{
if (!@ldap_close($this->connection))
{
@@ -117,6 +141,19 @@ class auth_login
}
}
/**
* Validate login credentials
*
* @param string $uname - The user name requesting access
* @param string $pass - Password to use (usually plain text)
* @param pointer &$newvals - pointer to array to accept other data read from database
* @param boolean $connect_only - TRUE to simply connect to the server
*
* @return integer result (AUTH_xxxx)
*
* On a successful login, &$newvals array is filled with the requested data from the server
*/
function login($uname, $pass, &$newvals, $connect_only = false)
{
/* Construct the full DN, eg:-
@@ -248,8 +285,8 @@ class auth_login
}
else
{
/* Login failed. Return false, together with the error code and text from
** the LDAP server. The common error codes and reasons are listed below :
/* Login failed. Return error code.
** The common error codes and reasons are listed below :
** (for iPlanet, other servers may differ)
** 19 - Account locked out (too many invalid login attempts)
** 32 - User does not exist

View File

@@ -1,37 +1,41 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_conf.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* LDAP configuration for alt_auth plugin
*
* $URL$
* $Id$
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
$eplug_admin = true;
require_once("../../class2.php");
require_once(e_ADMIN."auth.php");
require_once(e_HANDLER."form_handler.php");
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE."/admin_ldap_conf.php");
require_once('../../class2.php');
require_once(e_ADMIN.'auth.php');
require_once(e_HANDLER.'form_handler.php');
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_ldap_conf.php');
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
define('ALT_AUTH_ACTION', 'ldap');
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
$server_types[1]="LDAP";
$server_types[2]="ActiveDirectory";
$server_types[3]="eDirectory";
$server_types[1] = 'LDAP';
$server_types[2] = 'ActiveDirectory';
$server_types[3] = 'eDirectory';
$ldap_ver[1]="2";
$ldap_ver[2]="3";
$ldap_ver[1]='2';
$ldap_ver[2]='3';
$message = '';
if($_POST['update'])
@@ -48,28 +52,24 @@ if(!function_exists('ldap_connect'))
if($message)
{
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
$ldap['ldap_edirfilter'] == "";
$sql -> db_Select("alt_auth", "*", "auth_type = 'ldap' ");
while($row = $sql->db_Fetch())
{
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); // Encoding is new for 0.8
}
$ldap = altAuthGetParams('ldap');
if (!isset($ldap['ldap_edirfilter'])) $ldap['ldap_edirfilter'] == '';
//print_a($ldap);
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
$frm = new form;
$text = $frm -> form_open("post",e_SELF);
$text = $frm -> form_open('post',e_SELF);
$text .= "<table style='width:96%' class='fborder'>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_12."</td><td class='forumheader3'>";
$text .= $frm -> form_select_open("ldap_servertype");
foreach($server_types as $v)
{
$sel = ($ldap['ldap_servertype'] == $v) ? " Selected" : "";
$sel = ($ldap['ldap_servertype'] == $v) ? " Selected='selected'" : '';
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
@@ -98,7 +98,7 @@ $text .= $frm -> form_select_open("ldap_version");
foreach($ldap_ver as $v)
{
$sel = ($ldap['ldap_version'] == $v) ? " Selected" : "";
$sel = ($ldap['ldap_version'] == $v) ? " Selected='selected'" : "";
$text .= $frm -> form_option($v, $sel, $v);
}
@@ -106,7 +106,7 @@ $text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_7."<br /><span class='smalltext'>".LDAPLAN_8."</span></td><td class='forumheader3'>";
$text .= $frm -> form_text("ldap_edirfilter", 35, $ldap['ldap_edirfilter'], 120);
$text .= $frm -> form_text('ldap_edirfilter', 35, $ldap['ldap_edirfilter'], 120);
$text .= "<br /><span class='smalltext'>".LDAPLAN_9."<br />".htmlentities($current_filter)."</span></td></tr>";
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
@@ -115,16 +115,17 @@ $text .= "<br /><span class='smalltext'>".LDAPLAN_9."<br />".htmlentities($curre
$text .= alt_auth_get_field_list('ldap',$frm, $ldap, FALSE);
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
$text .= $frm -> form_button("submit", "update", LDAPLAN_13);
$text .= $frm -> form_button('submit', 'update', LDAPLAN_13);
$text .= "</td></tr>";
$text .= "</table>";
$text .= "</table>\n";
$text .= $frm -> form_close();
$ns -> tablerender(LDAPLAN_6,$text);
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('ldap',$frm));
e107::getRender()->tablerender(LDAPLAN_6,$text);
e107::getRender()->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('ldap',$frm));
require_once(e_ADMIN.'footer.php');
require_once(e_ADMIN."footer.php");
function ldap_conf_adminmenu()
{

View File

@@ -1,20 +1,24 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/otherdb_auth.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Alt_auth plugin - 'otherdb' authorisation handler
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
/*
@@ -29,35 +33,53 @@
class auth_login
{
var $Available;
var $ErrorText;
var $conf; // Configuration parameters
public $Available = FALSE; // Flag indicates whether DB connection available
public $ErrorText; // e107 error string on exit
private $conf; // Configuration parameters
function auth_login()
/**
* Read configuration
*
* @return AUTH_xxxx result code
*/
public function __construct()
{
global $sql;
$this->conf = array();
$this->ErrorText = '';
$sql -> db_Select("alt_auth", "*", "auth_type = 'otherdb' ");
while($row = $sql -> db_Fetch())
{
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$this->conf = altAuthGetParams('otherdb');
$this->Available = TRUE;
}
// Add the reconnect function in here - might be needed
function makeErrorText($extra = '')
/**
* Retrieve and construct error strings
*
* @todo - test whether reconnect to DB is required (shouldn't be)
*/
private function makeErrorText($extra = '')
{
$this->ErrorText = $extra;
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
//global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
//$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
}
function login($uname, $pword, &$newvals, $connect_only = FALSE)
/**
* Validate login credentials
*
* @param string $uname - The user name requesting access
* @param string $pass - Password to use (usually plain text)
* @param pointer &$newvals - pointer to array to accept other data read from database
* @param boolean $connect_only - TRUE to simply connect to the database
*
* @return integer result (AUTH_xxxx)
*
* On a successful login, &$newvals array is filled with the requested data from the server
*/
public function login($uname, $pword, &$newvals, $connect_only = FALSE)
{
//Attempt to open connection to sql database
if(!$res = mysql_connect($this->conf['otherdb_server'], $this->conf['otherdb_username'], $this->conf['otherdb_password']))

View File

@@ -1,54 +1,56 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Alt_auth plugin - 'otherdb' configuration
*
* $URL$
* $Id$
*
*/
/**
* e107 Alternate authorisation plugin
*
* @package e107_plugins
* @subpackage alt_auth
* @version $Id$;
*/
$eplug_admin = true;
require_once("../../class2.php");
require_once(e_ADMIN."auth.php");
require_once(e_HANDLER."form_handler.php");
require_once('../../class2.php');
require_once(e_ADMIN.'auth.php');
require_once(e_HANDLER.'form_handler.php');
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_otherdb_conf.php');
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
define('ALT_AUTH_ACTION', 'otherdb');
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
if($_POST['update'])
{
// $message = update_otherdb_prefs();
$message = alt_auth_post_options('otherdb');
}
if($message)
{
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
show_otherdb_form();
function show_otherdb_form()
{
global $sql, $tp, $ns;
$ns = e107::getRender();
$password_methods = ExtendedPasswordHandler::GetPasswordTypes(TRUE);
// $db_types = array("e107" => "mysql - e107 database", "mysql" => "mysql - generic database");
$sql -> db_Select("alt_auth", "*", "auth_type = 'otherdb' ");
$parm = array();
while($row = $sql->db_Fetch())
{
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$parm = altAuthGetParams('otherdb');
$frm = new form;
$text = $frm -> form_open("post", e_SELF);
@@ -60,13 +62,9 @@ function show_otherdb_form()
$text .= alt_auth_get_db_fields('otherdb', $frm, $parm, 'server|uname|pwd|db|table|ufield|pwfield|salt');
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_9."</td><td class='forumheader3'>";
$text .= $frm -> form_select_open("otherdb_password_method");
foreach($password_methods as $k => $v)
{
$sel = ($parm['otherdb_password_method'] == $k) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $k);
}
$text .= $frm -> form_select_close();
$text .= altAuthGetPasswordSelector('otherdb_password_method', $frm, $parm['otherdb_password_method'], TRUE);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
@@ -74,10 +72,10 @@ function show_otherdb_form()
$text .= alt_auth_get_field_list('otherdb',$frm, $parm, FALSE);
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
$text .= "</td></tr>";
$text .= $frm -> form_button('submit', 'update', LAN_ALT_UPDATESET);
$text .= '</td></tr>';
$text .= "</table>";
$text .= '</table>';
$text .= $frm -> form_close();
$ns -> tablerender(OTHERDB_LAN_10, $text);
@@ -85,7 +83,7 @@ function show_otherdb_form()
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('otherdb',$frm));
}
require_once(e_ADMIN."footer.php");
require_once(e_ADMIN.'footer.php');

View File

@@ -31,25 +31,26 @@ define('RADIUS_DEBUG',TRUE);
class auth_login
{
var $server;
var $secret;
var $port;
var $usr;
var $pwd;
var $ErrorText;
var $connection; // Handle to use on successful creation
var $result;
var $Available;
private $server;
private $secret;
private $port;
private $usr;
private $pwd;
private $connection; // Handle to use on successful creation
public $Available = FALSE; // Flag indicates whether DB connection available
public $ErrorText; // e107 error string on exit
function auth_login()
/**
* Read configuration, initialise connection to LDAP database
*
* @return AUTH_xxxx result code
*/
function __construct()
{
$this->copyAttribs = array();
$sql = new db;
$sql -> db_Select("alt_auth", "*", "auth_type = 'radius' ");
while($row = $sql -> db_Fetch())
{
$radius[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$radius = altAuthGetParams('radius');
$this->server = explode(',',$radius['radius_server']);
$this->port = 1812; // Assume fixed port number for now - 1812 (UDP) is listed for servers, 1645 for authentification. (1646, 1813 for accounting)
// (A Microsoft app note says 1812 is the RFC2026-compliant port number. (http://support.microsoft.com/kb/230786)
@@ -66,18 +67,22 @@ class auth_login
$this->ErrorText = '';
if(!function_exists('radius_auth_open'))
{
$this->Available = FALSE;
return false;
return AUTH_NORESOURCE;
}
if(!$this -> connect())
{
return AUTH_NOCONNECT;
}
$this->Available = TRUE;
return AUTH_SUCCESS;
}
/**
* Retrieve and construct error strings
*/
function makeErrorText($extra = '')
{
$this->ErrorText = $extra.radius_strerror($this->connection) ;
@@ -88,9 +93,13 @@ class auth_login
/**
* Try to connect to a radius server
*
* @return boolean TRUE for success, FALSE for failure
*/
function connect()
{
// Try to connect to a radius server
if (!($this->connection = radius_auth_open()))
{
$this->makeErrorText('RADIUS open failed: ') ;
@@ -109,6 +118,9 @@ class auth_login
/**
* Close the connection to the Radius server
*/
function close()
{
if ( !radius_close( $this->connection)) // (Not strictly necessary, but tidy)
@@ -124,6 +136,18 @@ class auth_login
/**
* Validate login credentials
*
* @param string $uname - The user name requesting access
* @param string $pass - Password to use (usually plain text)
* @param pointer &$newvals - pointer to array to accept other data read from database
* @param boolean $connect_only - TRUE to simply connect to the server
*
* @return integer result (AUTH_xxxx)
*
* On a successful login, &$newvals array is filled with the requested data from the server
*/
function login($uname, $pass, &$newvals, $connect_only = FALSE)
{
// Create authentification request