From 951bea859a62fce53e865d3ef6fc48be0cd6b993 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 8 Nov 2016 10:47:01 +0100 Subject: [PATCH] Dbug --- build/api/core/Authentification.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/build/api/core/Authentification.php b/build/api/core/Authentification.php index 325eca5..103a7e4 100644 --- a/build/api/core/Authentification.php +++ b/build/api/core/Authentification.php @@ -48,14 +48,18 @@ if( !isset($GLOBALS['TOKEN']) ) $GLOBALS['TOKEN'] = null; + echo "1. ".$GLOBALS['TOKEN']."\n"; + /* (1) Liste des permissions */ if( !isset($GLOBALS['PERM']) ) $GLOBALS['PERM'] = []; + echo "2. ".$GLOBALS['TOKEN']."\n"; /* (2) Gestion de AUTH (authentification) dans HEADER ---------------------------------------------------------*/ $GLOBALS['TOKEN'] = isset($_SERVER['PHP_AUTH_DIGEST']) ? $_SERVER['PHP_AUTH_DIGEST'] : ''; + echo "3. ".$GLOBALS['TOKEN']."\n"; /* (3) Gestion de AUTH en fonction du token ---------------------------------------------------------*/ @@ -64,10 +68,13 @@ else $GLOBALS['TOKEN'] = null; + echo "4. ".$GLOBALS['TOKEN']."\n"; + /* (4) On vérifie l'authentification par BDD ---------------------------------------------------------*/ if( !self::deepCheck() ) $GLOBALS['TOKEN'] = null; + echo "5. ".$GLOBALS['TOKEN']."\n"; } @@ -84,7 +91,7 @@ return false; - /* [2] Vérification de l'authentification + /* [2] Vérification du système =========================================================*/ /* (1) Fetch cyclic-hashing-system -> check file */ $fn = __BUILD__.'/api/chs/hash'; @@ -98,21 +105,23 @@ if( strlen($fc) !== 64 ) return false; - /* (3) Compares content */ + /* [3] Hash comparison + =========================================================*/ + /* (1) Compares content */ $hashed = self::secure_hash($GLOBALS['TOKEN']); - if( strlen($hashed) !== 64 || $hashed !== $fc ) + if( $hashed !== $fc ) return false; - /* (4) Stores new content */ + /* (2) Stores new content */ file_put_contents($fn, $GLOBALS['TOKEN']); - /* (5) Stores permission */ + /* (3) Stores permission */ if( !in_array('cyclic-hash', $GLOBALS['PERM']) ) $GLOBALS['PERM'][] = 'cyclic-hash'; - /* [3] Returns true if no error + /* [4] Returns true if no error =========================================================*/ return true;