Add more debug for authentication
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2996 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -172,13 +172,14 @@ class authentication
|
||||
/** Check all the REST API */
|
||||
public function verifAuthREST ()
|
||||
{
|
||||
if ($this->debug)
|
||||
echo "=== entering verifAuthREST (restMethods=".
|
||||
print_r ($this->restMethods, true).")\n";
|
||||
$authparams = new \authparams ($this->restMethods);
|
||||
$res = array ("email"=>"anonymous", "password"=>"anonymous");
|
||||
if ($authparams->email !== "anonymous" &&
|
||||
$authparams->password !== "anonymous")
|
||||
{
|
||||
if ($this->debug)
|
||||
echo "verifAuth ($authparams->email, $authparams->password)\n";
|
||||
$res = $this->verifAuth ($authparams->email, $authparams->password);
|
||||
}
|
||||
if (! is_array ($res))
|
||||
@@ -196,7 +197,9 @@ class authentication
|
||||
/** Check all the others pages of the site */
|
||||
public function verifAuthHTML ()
|
||||
{
|
||||
if ($this->debug) echo "verifAuthHTML() : ";
|
||||
if ($this->debug)
|
||||
echo "=== entering verifAuthHTML (htmlMethods=".
|
||||
print_r ($this->htmlMethods, true).")\n";
|
||||
$authparams = new \authparams ($this->htmlMethods);
|
||||
// Don't ask to the provider if anonymous is known
|
||||
if ($authparams->email === "anonymous" || $authparams->email === null)
|
||||
@@ -230,19 +233,26 @@ class authentication
|
||||
an exception if noting is found */
|
||||
private function verifAuth ($email, $password)
|
||||
{
|
||||
if ($this->debug)
|
||||
echo "Entering in verifAuth ($email, xxxxxxxx)\n";
|
||||
if (! is_array ($this->authMethods) || count ($this->authMethods) === 0)
|
||||
throw new \Exception ("No authentication method defined", 500);
|
||||
if (isset ($_SESSION["domframework"]["authentication"]["lastcheck"]) &&
|
||||
if ($this->debug < 2 &&
|
||||
isset ($_SESSION["domframework"]["authentication"]["lastcheck"]) &&
|
||||
$_SESSION["domframework"]["authentication"]["lastcheck"] + 180 <
|
||||
time ())
|
||||
{
|
||||
// Test the authentication each 3 minutes if there is a session, else
|
||||
// return the previous values
|
||||
if ($this->debug)
|
||||
echo "verifAuth : using auth cache (push in debug=2 to skip)\n";
|
||||
return $_SESSION["domframework"]["authentication"]["authcache"];
|
||||
}
|
||||
|
||||
foreach ($this->authMethods as $method)
|
||||
{
|
||||
if ($this->debug)
|
||||
echo "Authentication method=$method\n";
|
||||
if (! is_string ($method))
|
||||
throw new \Exception ("The authentication method is not a string", 500);
|
||||
$classname = "auth$method";
|
||||
@@ -256,6 +266,9 @@ class authentication
|
||||
{
|
||||
$this->authServers[$classname] = array ($this->authServers[$classname]);
|
||||
}
|
||||
if ($this->debug >= 2)
|
||||
echo "Authentication method=$method : authServers=".
|
||||
var_export ($this->authServers[$classname])."\n";
|
||||
if (! is_array ($this->authServers[$classname]) ||
|
||||
count ($this->authServers[$classname]) === 0)
|
||||
throw new \Exception ("No authentication server defined for method ".
|
||||
@@ -270,6 +283,8 @@ class authentication
|
||||
$authmethod = new $classname ();
|
||||
foreach ($serversParam as $param=>$value)
|
||||
{
|
||||
if ($this->debug)
|
||||
echo "Add param '$param' with value '$value' to auth$method\n";
|
||||
$authmethod->$param = $value;
|
||||
}
|
||||
$authmethod->connect ();
|
||||
|
||||
Reference in New Issue
Block a user