authentication : better error management in configuration (Exception in case of errors).
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2254 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -217,6 +217,8 @@ class authentication
|
|||||||
an exception if noting is found */
|
an exception if noting is found */
|
||||||
private function verifAuth ($email, $password)
|
private function verifAuth ($email, $password)
|
||||||
{
|
{
|
||||||
|
if (! is_array ($this->authMethods) || count ($this->authMethods) === 0)
|
||||||
|
throw new Exception ("No authentication method defined", 500);
|
||||||
if (isset ($_SESSION["domframework"]["authentication"]["lastcheck"]) &&
|
if (isset ($_SESSION["domframework"]["authentication"]["lastcheck"]) &&
|
||||||
$_SESSION["domframework"]["authentication"]["lastcheck"] + 180 <
|
$_SESSION["domframework"]["authentication"]["lastcheck"] + 180 <
|
||||||
time ())
|
time ())
|
||||||
@@ -228,19 +230,30 @@ class authentication
|
|||||||
|
|
||||||
foreach ($this->authMethods as $method)
|
foreach ($this->authMethods as $method)
|
||||||
{
|
{
|
||||||
|
if (! is_string ($method))
|
||||||
|
throw new Exception ("The authentication method is not a string", 500);
|
||||||
$classname = "auth$method";
|
$classname = "auth$method";
|
||||||
require_once ("domframework/$classname.php");
|
require_once ("domframework/$classname.php");
|
||||||
|
if (! array_key_exists ($classname, $this->authServers))
|
||||||
|
throw new Exception ("No authentication server '$classname' enabled",
|
||||||
|
500);
|
||||||
// If only one server is defined, the parameters can directely be pushed
|
// If only one server is defined, the parameters can directely be pushed
|
||||||
// to the classname
|
// to the classname
|
||||||
if (! is_array ($this->authServers[$classname]))
|
if (! is_array (reset ($this->authServers[$classname])))
|
||||||
{
|
{
|
||||||
$this->authServers[$classname] = array ($this->authServers[$classname]);
|
$this->authServers[$classname] = array ($this->authServers[$classname]);
|
||||||
}
|
}
|
||||||
|
if (! is_array ($this->authServers[$classname]) ||
|
||||||
|
count ($this->authServers[$classname]) === 0)
|
||||||
|
throw new Exception ("No authentication server defined for method ".
|
||||||
|
"'$method'", 500);
|
||||||
foreach ($this->authServers[$classname] as $key=>$serversParam)
|
foreach ($this->authServers[$classname] as $key=>$serversParam)
|
||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "Test auth server $method # $classname # $key\n";
|
echo "Test auth server $method # $classname # $key\n";
|
||||||
|
if (! is_array ($serversParam))
|
||||||
|
throw new Exception ("Auth Server $key configuration error : ".
|
||||||
|
"not an array", 500);
|
||||||
$authmethod = new $classname ();
|
$authmethod = new $classname ();
|
||||||
foreach ($serversParam as $param=>$value)
|
foreach ($serversParam as $param=>$value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user