Nouvelle librairie d'authentification

This commit is contained in:
Michael RICOIS 2015-04-08 12:11:17 +00:00
parent 2247249b35
commit f1ea90fb00
7 changed files with 407 additions and 204 deletions

View File

@ -1,20 +1,20 @@
<?php
// Generated by ZF's ./bin/classmap_generator.php
return array(
'Bootstrap' => dirname(__FILE__) . '/Bootstrap.php',
'AideController' => dirname(__FILE__) . '/controllers/AideController.php',
'ArborescenceController' => dirname(__FILE__) . '/controllers/ArborescenceController.php',
'ComptageController' => dirname(__FILE__) . '/controllers/ComptageController.php',
'DashboardController' => dirname(__FILE__) . '/controllers/DashboardController.php',
'EnrichissementController' => dirname(__FILE__) . '/controllers/EnrichissementController.php',
'ErreurController' => dirname(__FILE__) . '/controllers/ErreurController.php',
'ErrorController' => dirname(__FILE__) . '/controllers/ErrorController.php',
'FieldsController' => dirname(__FILE__) . '/controllers/FieldsController.php',
'GestionController' => dirname(__FILE__) . '/controllers/GestionController.php',
'IndexController' => dirname(__FILE__) . '/controllers/IndexController.php',
'UploadController' => dirname(__FILE__) . '/controllers/UploadController.php',
'UserController' => dirname(__FILE__) . '/controllers/UserController.php',
'Zend_View_Helper_DataDate' => dirname(__FILE__) . '/views/default/helpers/DataDate.php',
'Zend_View_Helper_Field' => dirname(__FILE__) . '/views/default/helpers/Field.php',
'Zend_View_Helper_ProfileLink' => dirname(__FILE__) . '/views/default/helpers/ProfileLink.php',
'Bootstrap' => dirname(__FILE__) . '//Bootstrap.php',
'AideController' => dirname(__FILE__) . '//controllers/AideController.php',
'ArborescenceController' => dirname(__FILE__) . '//controllers/ArborescenceController.php',
'ComptageController' => dirname(__FILE__) . '//controllers/ComptageController.php',
'DashboardController' => dirname(__FILE__) . '//controllers/DashboardController.php',
'EnrichissementController' => dirname(__FILE__) . '//controllers/EnrichissementController.php',
'ErreurController' => dirname(__FILE__) . '//controllers/ErreurController.php',
'ErrorController' => dirname(__FILE__) . '//controllers/ErrorController.php',
'FieldsController' => dirname(__FILE__) . '//controllers/FieldsController.php',
'GestionController' => dirname(__FILE__) . '//controllers/GestionController.php',
'IndexController' => dirname(__FILE__) . '//controllers/IndexController.php',
'UploadController' => dirname(__FILE__) . '//controllers/UploadController.php',
'UserController' => dirname(__FILE__) . '//controllers/UserController.php',
'Zend_View_Helper_DataDate' => dirname(__FILE__) . '//views/default/helpers/DataDate.php',
'Zend_View_Helper_Field' => dirname(__FILE__) . '//views/default/helpers/Field.php',
'Zend_View_Helper_ProfileLink' => dirname(__FILE__) . '//views/default/helpers/ProfileLink.php',
);

View File

@ -1,35 +1,32 @@
<?php
class UserController extends Zend_Controller_Action
{
/**
* Gestion de l'authentification
*/
public function loginAction()
{
$this->view->headLink()->appendStylesheet('/themes/default/styles/signin.css', 'all');
//@todo : gestion des affichages particuliers pour les clients
$this->view->headTitle()->append('Connexion');
$form = new Application_Form_Login();
$this->view->form = $form;
$request = $this->getRequest();
if ($request->isPost()) {
if ( $request->isPost() ) {
$formData = $request->getPost ();
if ($form->isValid($formData)) {
if ( $form->isValid($formData) ) {
$login = $form->getValue('login');
$pass = $form->getValue('pass');
$auth = Zend_Auth::getInstance();
$authAdapter = new Scores_AuthAdapter($login, md5($login.'|'.$pass));
$result = $auth->authenticate($authAdapter);
if (!$result->isValid()){
$this->view->message = '';
Zend_Registry::get('firebug')->info($result);
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
$authAdapter = new Scores_Auth_Adapter_Ws($login, md5($login.'|'.$pass));
$result = $auth->authenticate($authAdapter);
if ( $result->isValid() ) {
$this->redirect('/');
} else {
$this->_redirect('/');
$this->view->message = '';
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
}
}
}

View File

@ -9,169 +9,204 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = $request->getControllerName();
$action = $request->getActionName();
$checkAuth = true;
if ($request->getControllerName()=='user' &&
($request->getActionName()=='login' || $request->getActionName()=='logout') ) {
$checkAuth = false;
// --- Pas d'authentification sur la demande d'authentification
if ( $controller == 'user' && in_array($action, array('login', 'logout')) ) {
$checkAuth = false;
}
if ($checkAuth)
{
if ($checkAuth) {
$login = $request->getParam('login');
$pass = $request->getParam('pass', '');
$hach = $request->getParam('hach');
$checkIp = $request->getParam('checkIp');
if (!empty($hach)) {
$pass = $hach;
}
$auth = Zend_Auth::getInstance();
//Est ce que l'on a checkIp=only lors de la requête
$iponly = false;
if ($checkIp=='only') {
$hach = 'iponly:'.$_SERVER['REMOTE_ADDR'];
$iponly = true;
}
//On vérifie le tout lors d'une connexion par url
// --- On vérifie le tout lors d'une connexion par url
if ( !empty($login) && !empty($hach) ) {
$authAdapter = new Scores_AuthAdapter($login, $hach, $iponly);
$authAdapter = new Scores_Auth_Adapter_Ws($login, $pass);
$result = $auth->authenticate($authAdapter);
if (!$result->isValid()) {
$messageF = '';
foreach ($result->getMessages() as $message) {
$messageF.= $message."<br/>";
}
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('message', $messageF);
if ( $result->isValid() ) {
$storage = new Zend_Auth_Storage_Session();
$session = new Zend_Session_Namespace($storage->getNamespace());
//$session->setExpirationSeconds(86400);
$auth->setStorage($storage);
} else {
$storage = new Zend_Auth_Storage_Session();
$session = new Zend_Session_Namespace($storage->getNamespace());
$auth->setStorage($storage);
$messageDisplay = "";
foreach ($result->getMessages() as $message) {
$messageDisplay.= $message."<br/>";
}
$layout = Zend_Layout::getMVCInstance();
if ( $layout->isEnabled() ){
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('message', $messageDisplay);
} else {
echo $messageDisplay;
}
}
//Sinon on reste sur le standard
// --- Sinon on reste sur le standard
} else {
$layout = Zend_Layout::getMVCInstance();
//Authentifié => on met à jour la session
if ( $auth->hasIdentity() && time() < $auth->getIdentity()->time ) {
$identity = $auth->getIdentity();
$identity->time = time() + $identity->timeout;
if ( !isset($identity->dateContrat) && $layout->isEnabled() ) {
//Get customer's params
$paramsM = new Application_Model_CiblageCustomerParams();
$sql = $paramsM->select()
->where('idClient = ?', $identity->idClient)
//@todo : add service from WebService
->order('dateContrat DESC')->limit(1);
$params = $paramsM->fetchAll($sql)->toArray();
if (count($params)>0) {
$identity->filterRNCS = $params[0]['filterRNCS'];
$identity->licenceINSEE = $params[0]['licenceINSEE'];
$identity->limitLines = $params[0]['limitLines'];
$identity->limitFiles = $params[0]['limitFiles'];
$identity->immediatExtract = $params[0]['immediatExtract'];
$identity->dateContrat = $params[0]['dateContrat'];
$identity->periodContrat = $params[0]['periodContrat'];
$identity->priceLine = $params[0]['priceLine'];
$identity->forfait = $params[0]['forfait'];
// --- Authentifié
if ( $auth->hasIdentity() ) {
// --- Mise à jour du délai de connexion
if ( time() < $auth->getIdentity()->time ) {
$identity = $auth->getIdentity();
$identity->time = time() + $identity->timeout;
// --- Vérification des paramètres du contrat
if ( $identity->dateContrat === null && $layout->isEnabled() ) {
// --- Get customer's params
$paramsM = new Application_Model_CiblageCustomerParams();
$sql = $paramsM->select()
->where('idClient = ?', $identity->idClient)
//@todo : add service from WebService
->order('dateContrat DESC')->limit(1);
$params = $paramsM->fetchRow($sql);
if ( $params !== null ) {
$identity->filterRNCS = $params->filterRNCS;
$identity->licenceINSEE = $params->licenceINSEE;
$identity->limitLines = $params->limitLines;
$identity->limitFiles = $params->limitFiles;
$identity->immediatExtract = $params->immediatExtract;
$identity->dateContrat = $params->dateContrat;
$identity->periodContrat = $params->periodContrat;
$identity->priceLine = $params->priceLine;
$identity->forfait = $params->forfait;
}
// --- Get user's preference
$prefsM = new Application_Model_CiblagePrefs();
$pref = $prefsM->find($identity->username)->current();
if ( $pref !== null ) {
$identity->preferences = json_decode($pref->json);
}
// --- Add a global value to join filterRNCS and preferences RNCS
if ( $identity->filterRNCS ) {
$identity->globalRNCS = 1;
}
if ( isset($identity->preferences->filter->rncs)
&& $identity->preferences->filter->rncs ==1 ) {
$identity->globalRNCS = 1;
}
}
//Get user's preference
$prefsM = new Application_Model_CiblagePrefs();
$pref = $prefsM->find($identity->username)->current();
if ($pref) {
$identity->preferences = json_decode($pref->json, true);
}
//Add a global value to join filterRNCS and preferences RNCS
if ($identity->filterRNCS) {
$identity->globalRNCS = 1;
}
if (isset($identity->preferences['filter']['rncs'])
&& $identity->preferences['filter']['rncs']==1) {
$identity->globalRNCS = 1;
}
}
//No contrat define
if ( $identity->dateContrat=='0000-00-00 00:00:00' ) {
//If no params are detected, display a message to contact support
$request->setModuleName('default')
->setControllerName('aide')
->setActionName('message')
->setParam('typeMsg', 'support');
}
//Check dateContrat and calculate end of contrat
else {
$hour = intval(substr($identity->dateContrat,11,2));
$min = intval(substr($identity->dateContrat,14,2));
$sec = intval(substr($identity->dateContrat,17,2));
$month = intval(substr($identity->dateContrat,5,2)) + $identity->periodContrat;
$day = intval(substr($identity->dateContrat,8,2));
$year = intval(substr($identity->dateContrat,0,4));
$dateFinContrat = mktime($hour,$min,$sec,$month,$day,$year);
if ( time() > $dateFinContrat ) {
// --- No contrat define
if ( $identity->dateContrat == '0000-00-00 00:00:00' || $identity->dateContrat === null ) {
// --- If no params are detected, display a message to contact support
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('message', "Votre Contrat est arrivé à expiration.");
->setControllerName('aide')
->setActionName('message')
->setParam('typeMsg', 'support');
}
// --- Check dateContrat and calculate end of contrat
else {
$hour = intval(substr($identity->dateContrat,11,2));
$min = intval(substr($identity->dateContrat,14,2));
$sec = intval(substr($identity->dateContrat,17,2));
$month = intval(substr($identity->dateContrat,5,2)) + $identity->periodContrat;
$day = intval(substr($identity->dateContrat,8,2));
$year = intval(substr($identity->dateContrat,0,4));
$dateFinContrat = mktime($hour,$min,$sec,$month,$day,$year);
if ( time() > $dateFinContrat ) {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('message', "Votre Contrat est arrivé à expiration.");
}
}
// --- Sauvegarde des paramètres
$auth->getStorage()->write($identity);
// --- Activation profil SuperAdministrateur
if ( $identity->profil == "SuperAdministrateur" ) {
$view = $layout->getView();
$view->admin = true;
}
if (Zend_Session::namespaceIsset('login')){
Zend_Session::namespaceUnset('login');
}
}
$auth->getStorage()->write($identity);
if ( $identity->profil=="SuperAdministrateur" ) {
$view = $layout->getView();
$view->admin = true;
// --- Temps de connexion dépassé
elseif ( time() > $auth->getIdentity()->time ) {
$auth->clearIdentity();
$storage = $auth->getStorage();
Zend_Session::namespaceUnset($storage->getNamespace());
if ( !$request->isXmlHttpRequest() ) {
$session = new Zend_Session_Namespace('login');
$session->url = $_SERVER['REQUEST_URI'];
}
if ( $request->getControllerName()=='index' && $request->getActionName()=='index' ) {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('login');
} else {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('ajax', $request->isXmlHttpRequest());
}
}
}
// --- Pas Authentifié
else {
if ( $request->isXmlHttpRequest() ) {
//Zend_Registry::get('firebug')->info($identity);
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('ajax', 1);
if (Zend_Session::namespaceIsset('login')){
Zend_Session::namespaceUnset('login');
}
} else {
} elseif ($auth->hasIdentity() && time() > $auth->getIdentity()->time ) {
$session = new Zend_Session_Namespace('login');
$session->url = $_SERVER['REQUEST_URI'];
if ( $request->getControllerName()=='index' && $request->getActionName()=='index' ) {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('login');
} else {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('ajax', $request->isXmlHttpRequest());
}
} else {
if ($request->isXmlHttpRequest()) {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout')
->setParam('ajax', 1);
} else {
$session = new Zend_Session_Namespace('login');
$session->url = $_SERVER['REQUEST_URI'];
$request->setModuleName('default')
->setControllerName('user')
->setActionName('login');
}
$request->setModuleName('default')
->setControllerName('user')
->setActionName('login');
}
}
}
}

View File

@ -1,26 +1,26 @@
<?php
// Generated by ZF's ./bin/classmap_generator.php
return array(
'Application_Controller_Plugin_Auth' => dirname(__FILE__) . '/Controller/Plugin/Auth.php',
'Application_Controller_Plugin_Comptage' => dirname(__FILE__) . '/Controller/Plugin/Comptage.php',
'Application_Controller_Plugin_DataDate' => dirname(__FILE__) . '/Controller/Plugin/DataDate.php',
'Application_Controller_Plugin_Lang' => dirname(__FILE__) . '/Controller/Plugin/Lang.php',
'Application_Controller_Plugin_Menu' => dirname(__FILE__) . '/Controller/Plugin/Menu.php',
'Application_Form_Login' => dirname(__FILE__) . '/Form/Login.php',
'Application_Model_CiblageCodePostaux' => dirname(__FILE__) . '/Model/CiblageCodePostaux.php',
'Application_Model_CiblageComptages' => dirname(__FILE__) . '/Model/CiblageComptages.php',
'Application_Model_CiblageCriteres' => dirname(__FILE__) . '/Model/CiblageCriteres.php',
'Application_Model_CiblageCustomerParams' => dirname(__FILE__) . '/Model/CiblageCustomerParams.php',
'Application_Model_CiblageDepartements' => dirname(__FILE__) . '/Model/CiblageDepartements.php',
'Application_Model_CiblageEnrichissementIdentifiants' => dirname(__FILE__) . '/Model/CiblageEnrichissementIdentifiants.php',
'Application_Model_CiblageEnrichissementProfils' => dirname(__FILE__) . '/Model/CiblageEnrichissementProfils.php',
'Application_Model_CiblageFormeJuridique' => dirname(__FILE__) . '/Model/CiblageFormeJuridique.php',
'Application_Model_CiblageMinMax' => dirname(__FILE__) . '/Model/CiblageMinMax.php',
'Application_Model_CiblageNaf' => dirname(__FILE__) . '/Model/CiblageNaf.php',
'Application_Model_CiblagePrefs' => dirname(__FILE__) . '/Model/CiblagePrefs.php',
'Application_Model_CiblageRegions' => dirname(__FILE__) . '/Model/CiblageRegions.php',
'Application_Model_Sdv1Clients' => dirname(__FILE__) . '/Model/Sdv1Clients.php',
'Application_Model_Sdv1SphinxIdx' => dirname(__FILE__) . '/Model/Sdv1SphinxIdx.php',
'Application_Model_Sdv1Utilisateurs' => dirname(__FILE__) . '/Model/Sdv1Utilisateurs.php',
'Application_Model_Sdv1UtilisateursService' => dirname(__FILE__) . '/Model/Sdv1UtilisateursService.php',
'Application_Controller_Plugin_Auth' => dirname(__FILE__) . '//Controller/Plugin/Auth.php',
'Application_Controller_Plugin_Comptage' => dirname(__FILE__) . '//Controller/Plugin/Comptage.php',
'Application_Controller_Plugin_DataDate' => dirname(__FILE__) . '//Controller/Plugin/DataDate.php',
'Application_Controller_Plugin_Lang' => dirname(__FILE__) . '//Controller/Plugin/Lang.php',
'Application_Controller_Plugin_Menu' => dirname(__FILE__) . '//Controller/Plugin/Menu.php',
'Application_Form_Login' => dirname(__FILE__) . '//Form/Login.php',
'Application_Model_CiblageCodePostaux' => dirname(__FILE__) . '//Model/CiblageCodePostaux.php',
'Application_Model_CiblageComptages' => dirname(__FILE__) . '//Model/CiblageComptages.php',
'Application_Model_CiblageCriteres' => dirname(__FILE__) . '//Model/CiblageCriteres.php',
'Application_Model_CiblageCustomerParams' => dirname(__FILE__) . '//Model/CiblageCustomerParams.php',
'Application_Model_CiblageDepartements' => dirname(__FILE__) . '//Model/CiblageDepartements.php',
'Application_Model_CiblageEnrichissementIdentifiants' => dirname(__FILE__) . '//Model/CiblageEnrichissementIdentifiants.php',
'Application_Model_CiblageEnrichissementProfils' => dirname(__FILE__) . '//Model/CiblageEnrichissementProfils.php',
'Application_Model_CiblageFormeJuridique' => dirname(__FILE__) . '//Model/CiblageFormeJuridique.php',
'Application_Model_CiblageMinMax' => dirname(__FILE__) . '//Model/CiblageMinMax.php',
'Application_Model_CiblageNaf' => dirname(__FILE__) . '//Model/CiblageNaf.php',
'Application_Model_CiblagePrefs' => dirname(__FILE__) . '//Model/CiblagePrefs.php',
'Application_Model_CiblageRegions' => dirname(__FILE__) . '//Model/CiblageRegions.php',
'Application_Model_Sdv1Clients' => dirname(__FILE__) . '//Model/Sdv1Clients.php',
'Application_Model_Sdv1SphinxIdx' => dirname(__FILE__) . '//Model/Sdv1SphinxIdx.php',
'Application_Model_Sdv1Utilisateurs' => dirname(__FILE__) . '//Model/Sdv1Utilisateurs.php',
'Application_Model_Sdv1UtilisateursService' => dirname(__FILE__) . '//Model/Sdv1UtilisateursService.php',
);

View File

@ -0,0 +1,102 @@
<?php
class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
{
protected $_username;
protected $_password;
protected $_hash;
protected $_timeout = 3600;
protected $checkWs = false;
protected $clients = array();
/**
*
* @param string $username
* @param string $password
* @param boolean $checkWs
*/
public function __construct($username, $password, $checkWs = false)
{
$this->_username = $username;
$this->_password = $password;
$this->_hash = md5($username.'|'.$password);
$this->checkWs = $checkWs;
}
/**
* Limit access to only client IDs
* @param array $id
*/
public function limitClient($id = null)
{
if (is_array($id) && count($id)>0) {
$this->clients = $id;
}
}
/**
* Override the timeout
* @param integer $seconds
*/
public function setTimeout($seconds = null)
{
if ($seconds===null)
return;
$this->_timeout = $seconds;
}
/**
* (non-PHPdoc)
* @see Zend_Auth_Adapter_Interface::authenticate()
*/
public function authenticate()
{
$userM = new Application_Model_Sdv1Utilisateurs();
$sql = $userM->select()
->setIntegrityCheck(false)
->from(array('u'=>'sdv1.utilisateurs'), array('u.idClient', 'u.id', 'u.login', 'u.password'))
->join(array('c'=>'sdv1.clients'), 'u.idClient = c.id', array('c.timeout'))
->where('u.login=?', $this->_username)
->where('u.actif=?', 1)
->where('u.deleted=?', 0)
->where('c.actif=?','Oui');
if ( count($this->clients) > 0 ) {
$sql->where('u.idClient IN('.join(',',$this->clients).')');
}
if ($this->checkWs) {
$sql->where('u.accesWS=?',1);
}
$result = $userM->fetchRow($sql);
$identity = new stdClass();
$identity->username = $this->_username;
$identity->hash = $this->_hash;
if ( null === $result ) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity);
} else {
if ( $this->_password == $result->password
|| $this->_password == md5($result->login.'|'.$result->password) ) {
$identity->id = $result->id;
$identity->idClient = $result->idClient;
$timeout = (!empty($result->timeout)) ? $result->timeout : $this->_timeout;
$identity->timeout = $timeout;
$identity->time = time() + $timeout;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity);
}
}
}
}

View File

@ -1,27 +1,71 @@
<?php
class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
{
/**
* Identifiant de l'utilisateur
* @var string
*/
protected $_username;
/**
* Password
* @var string
*/
protected $_password;
/**
* Timeout
* @var int
*/
protected $_timeout = 1800;
/**
* Marqueur de vérification IP (en iponly)
* @var boolean
*/
protected $_checkIp = false;
/**
* Liste des IPs des frontends (proxy)
* @var array
*/
protected $listProxyIp = array(
'62.210.222.34',
);
/**
* Authentification par WS
* @param string $username
* @param string $password
* @param boolean $iponly
*/
public function __construct($username, $password, $iponly = false)
{
$this->_username = $username;
$this->_password = $password;
if ($iponly){
$this->_password = 'iponly:'.$_SERVER['REMOTE_ADDR'];
if ($iponly){
$ip = $_SERVER['REMOTE_ADDR'];
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$this->_password = 'iponly:'.$ip;
}
$this->_checkIp = $iponly;
}
/**
* (non-PHPdoc)
* @see Zend_Auth_Adapter_Interface::authenticate()
*/
public function authenticate()
{
$adressIp = $_SERVER['REMOTE_ADDR'];
$ip = $_SERVER['REMOTE_ADDR'];
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$ws = new Scores_Ws($this->_username, $this->_password);
$InfosLogin = $ws->getInfosLogin($this->_username, $adressIp);
$InfosLogin = $ws->getInfosLogin($this->_username, $ip);
$identity = new stdClass();
$identity->username = $this->_username;
$identity->password = $this->_password;
@ -32,24 +76,33 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
$identity->droitsClients = $InfosLogin->result->droitsClients;
$identity->nom = $InfosLogin->result->nom;
$identity->prenom = $InfosLogin->result->prenom;
$identity->tel = $InfosLogin->result->tel;
$identity->fax = $InfosLogin->result->fax;
$identity->mobile = $InfosLogin->result->mobile;
$identity->id = $InfosLogin->result->id;
$identity->idClient = $InfosLogin->result->idClient;
$identity->reference = $InfosLogin->result->reference;
$identity->nbReponses = $InfosLogin->result->nbReponses;
$identity->typeScore = $InfosLogin->result->typeScore;
$identity->dateValidation = $InfosLogin->result->dateValidation;
$identity->nombreConnexions = $InfosLogin->result->nombreConnexions;
$identity->dateDerniereConnexion = $InfosLogin->result->dateDerniereConnexion;
$identity->dateDebutCompte = $InfosLogin->result->dateDebutCompte;
$identity->dateDebutCompte = $InfosLogin->result->dateDebutCompte;
$identity->dateFinCompte = $InfosLogin->result->dateFinCompte;
$identity->ip = $adressIp;
$identity->acceptationCGU = $InfosLogin->result->acceptationCGU;
$identity->ip = $ip;
$identity->version = $InfosLogin->result->version;
$identity->modeEdition = false;
$timeout = (!empty($InfosLogin->result->timeout)) ? $InfosLogin->result->timeout : $this->_timeout;
$identity->timeout = $timeout;
$identity->time = time() + $timeout;
$lang = in_array($InfosLogin->result->lang, array('fr','en')) ? $InfosLogin->result->lang : 'fr';
$identity->lang = $lang;
$identity->langtmp = $lang;
/*
* Adresse Ip interdites
*/
@ -73,7 +126,7 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
}
// Renvoi
if ( is_string($InfosLogin) || $InfosLogin->error->errnum!=0){
if ( is_string($InfosLogin) || $InfosLogin->error->errnum != 0 ) {
$message = $InfosLogin;
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array($message));
} elseif ($this->_username == $InfosLogin->result->login) {
@ -84,9 +137,13 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
}
/**
* Controle si une adresse IP est dans une liste des IP communiquées sous la forme 192.168.3.5-192.68.3.10;192.168.3.*;192.168.3.10
* @param string $strPlageIP La plage d'adresses IP
* @param string $adresseIP L'adresse IP à tester
* Controle si une adresse IP est dans une liste des IP communiquées sous la forme
* 192.168.3.5-192.68.3.10;192.168.3.*;192.168.3.10
* @param string $strPlageIP
* La plage d'adresses IP
* @param string $adresseIP
* L'adresse IP à tester
* @return boolean
*/
protected function checkPlagesIp($strPlageIP, $adresseIP)
{
@ -134,7 +191,8 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
* @param string $ip Adresse IP
* @return integer
*/
protected function getIpNumber($ip) {
protected function getIpNumber($ip)
{
$tab=explode('.', $ip);
return (($tab[0]*256*256*256) + ($tab[1]*256*256) + ($tab[2]*256) + ($tab[3]));
}

View File

@ -1,10 +1,21 @@
<?php
// Generated by ZF's ./bin/classmap_generator.php
return array(
'Scores_AuthAdapter' => dirname(__FILE__) . '/AuthAdapter.php',
'Ciblage' => dirname(__FILE__) . '/Ciblage.php',
'Enrichissement' => dirname(__FILE__) . '/Enrichissement.php',
'Scores_Fields' => dirname(__FILE__) . '/Fields.php',
'Mail' => dirname(__FILE__) . '/Mail.php',
'Scores_Ws' => dirname(__FILE__) . '/Ws.php',
'Scores_Auth_Adapter_Db' => dirname(__FILE__) . '//Auth/Adapter/Db.php',
'Scores_Auth_Adapter_Ws' => dirname(__FILE__) . '//Auth/Adapter/Ws.php',
'Scores_Ciblage_Engine' => dirname(__FILE__) . '//Ciblage/Engine.php',
'Scores_Ciblage_Extract' => dirname(__FILE__) . '//Ciblage/Extract.php',
'Scores_Ciblage_Field_List' => dirname(__FILE__) . '//Ciblage/Field/List.php',
'Scores_Ciblage_Field_Many' => dirname(__FILE__) . '//Ciblage/Field/Many.php',
'Scores_Ciblage_Field_One' => dirname(__FILE__) . '//Ciblage/Field/One.php',
'Scores_Ciblage_Field_Range' => dirname(__FILE__) . '//Ciblage/Field/Range.php',
'Scores_Ciblage_Field_RangeDate' => dirname(__FILE__) . '//Ciblage/Field/RangeDate.php',
'Scores_Ciblage_Field_RangeInput' => dirname(__FILE__) . '//Ciblage/Field/RangeInput.php',
'Scores_Ciblage_Field_Search' => dirname(__FILE__) . '//Ciblage/Field/Search.php',
'Scores_Ciblage_Field_Tag' => dirname(__FILE__) . '//Ciblage/Field/Tag.php',
'Scores_Ciblage_Field_Tree' => dirname(__FILE__) . '//Ciblage/Field/Tree.php',
'Scores_Ciblage_FieldList' => dirname(__FILE__) . '//Ciblage/FieldList.php',
'Scores_Ciblage_Session' => dirname(__FILE__) . '//Ciblage/Session.php',
'Mail' => dirname(__FILE__) . '//Mail.php',
'Scores_Ws' => dirname(__FILE__) . '//Ws.php',
);