[module/authentification/renew] created
This commit is contained in:
parent
9a7f7f464b
commit
32899286f7
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace api\core;
|
||||||
|
|
||||||
|
use \error\core\Error;
|
||||||
|
|
||||||
|
|
||||||
|
class authentification{
|
||||||
|
|
||||||
|
|
||||||
|
/* RENEW CYCLING HASH
|
||||||
|
*
|
||||||
|
* @hash<String> New hash
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function renew($args){
|
||||||
|
extract($args);
|
||||||
|
|
||||||
|
/* (1) Fetch cyclic-hashing-system -> check file */
|
||||||
|
$fn = __BUILD__.'/api/chs/hash';
|
||||||
|
|
||||||
|
if( !is_file($fn) )
|
||||||
|
return ['ModuleError'=>Error::UnreachableResource];
|
||||||
|
|
||||||
|
/* (2) Stores new hash */
|
||||||
|
file_put_contents($fn, $hash);
|
||||||
|
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -72,6 +72,10 @@
|
||||||
// Mauvais format de fichier
|
// Mauvais format de fichier
|
||||||
const FormatError = 18;
|
const FormatError = 18;
|
||||||
|
|
||||||
|
/* Cyclic Hash Error */
|
||||||
|
// Expired
|
||||||
|
const CyclicHashExpired = 19;
|
||||||
|
|
||||||
/* Erreur au niveau javascript */
|
/* Erreur au niveau javascript */
|
||||||
//const JavascriptError = 19; // -> géré en js
|
//const JavascriptError = 19; // -> géré en js
|
||||||
|
|
||||||
|
@ -85,32 +89,33 @@
|
||||||
*/
|
*/
|
||||||
public static function explicit($error){
|
public static function explicit($error){
|
||||||
switch($error){
|
switch($error){
|
||||||
case self::Success: return "Tout s'est bien deroulé."; break;
|
case self::Success: return "All right man!"; break;
|
||||||
|
|
||||||
case self::ParsingFailed: return "La lecture du fichier JSON ou XML a echouée."; break;
|
case self::ParsingFailed: return "Parsing failed (json, xml, etc). Check your format."; break;
|
||||||
|
|
||||||
case self::InvalidFlags: return "Les spécifications (drapeaux) sont incorrects."; break;
|
case self::InvalidFlags: return "You sent invalid flags."; break;
|
||||||
case self::UnreachableResource: return "La ressource n'existe pas (404)."; break;
|
case self::UnreachableResource: return "Resource unreachable."; break;
|
||||||
case self::MissingPath: return "Le chemin de délégation n'a pas été renseigné."; break;
|
case self::MissingPath: return "The @path is missing"; break;
|
||||||
case self::WrongPathModule: return "Le chemin de délégation est incorrect ('nomModule/nomMethode')."; break;
|
case self::WrongPathModule: return "Invalid @path ('moduleName/methodName')."; break;
|
||||||
case self::WrongPathRepo: return "Le chemin de délégation est incorrect ('nomRepo/nomMethode')."; break;
|
case self::WrongPathRepo: return "Invalid @path ('repoName/methodName')."; break;
|
||||||
case self::UnknownModule: return "Le module n'existe pas."; break;
|
case self::UnknownModule: return "Module not found."; break;
|
||||||
case self::UnknownRepo: return "Le repo n'existe pas."; break;
|
case self::UnknownRepo: return "Repository not found."; break;
|
||||||
case self::UnknownMethod: return "Le methode n'existe pas."; break;
|
case self::UnknownMethod: return "The method doesn't exist."; break;
|
||||||
case self::UncallableMethod: return "Le methode n'est pas amorçable."; break;
|
case self::UncallableMethod: return "The method can't be called."; break;
|
||||||
|
|
||||||
case self::ParamError: return "Un ou plusieurs paramètres sont manquants ou incorrects."; break;
|
case self::ParamError: return "Missing or wrong arguments."; break;
|
||||||
case self::ModuleError: return "Erreur lors du traitement du module."; break;
|
case self::ModuleError: return "Module error."; break;
|
||||||
case self::RepoError: return "Erreur lors du traitement du repo."; break;
|
case self::RepoError: return "Repository error."; break;
|
||||||
|
|
||||||
case self::PDOConnection: return "La connexion avec la base de données a echouée."; break;
|
case self::PDOConnection: return "Database connection failed."; break;
|
||||||
|
|
||||||
case self::TokenError: return "Le token de connection est absent, érroné ou expiré."; break;
|
case self::TokenError: return "Missing or wrong token."; break;
|
||||||
case self::PermissionError: return "Vous n'avez pas la permission d'effectuer cette action."; break;
|
case self::PermissionError: return "Permission denied."; break;
|
||||||
case self::UploadError: return "Une erreur d'upload est survenue."; break;
|
case self::UploadError: return "Upload error"; break;
|
||||||
case self::FormatError: return "Le fichier n'est pas au bon format."; break;
|
case self::FormatError: return "Format error."; break;
|
||||||
|
case self::CyclicHashExpired: return "Cyclic hash has to be renewed."; break;
|
||||||
|
|
||||||
default: return "Description d'erreur inconnue..."; break;
|
default: return "Unknown Error..."; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erreur inconnue
|
// Erreur inconnue
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?php define('__ROOT__', dirname(dirname(__FILE__)));
|
|
||||||
|
|
||||||
require_once __ROOT__.'/al.php';
|
|
||||||
|
|
||||||
use api\core\Authentification;
|
|
||||||
|
|
||||||
|
|
||||||
var_dump( $stored=Authentification::secure_hash('some-password', 1000) );
|
|
||||||
var_dump( $given=Authentification::secure_hash('some-password', 999) );
|
|
||||||
var_dump( Authentification::secure_hash($given) );
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in New Issue