Diverses corrections
This commit is contained in:
parent
e2d59d385a
commit
60fe74b931
@ -21,8 +21,8 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
$checkAuth = false;
|
||||
}
|
||||
|
||||
if ($checkAuth)
|
||||
{
|
||||
if ($checkAuth) {
|
||||
|
||||
$login = $request->getParam('login');
|
||||
$pass = $request->getParam('pass', '');
|
||||
$hach = $request->getParam('hach');
|
||||
@ -30,17 +30,22 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
//Est ce que l'on a checkIp=only lors de la requête
|
||||
$iponly = false;
|
||||
$mode = null;
|
||||
// --- Mode checkIp=only
|
||||
if ($checkIp == 'only') {
|
||||
$hach = 'iponly:'.$_SERVER['REMOTE_ADDR'];
|
||||
$iponly = true;
|
||||
$mode = 'iponly';
|
||||
}
|
||||
|
||||
// --- On vérifie le tout lors d'une connexion par url
|
||||
if ( !empty($login) && !empty($hach) ) {
|
||||
|
||||
$authAdapter = new Scores_Auth_Adapter_Ws($login, $hach, $iponly);
|
||||
// --- Mode hach
|
||||
if ($mode === null) {
|
||||
$mode = 'hach';
|
||||
}
|
||||
|
||||
$authAdapter = new Scores_Auth_Adapter_Ws($login, $hach, $mode);
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
|
||||
if ( $result->isValid() ) {
|
||||
|
@ -25,6 +25,12 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
|
||||
*/
|
||||
protected $_checkIp = false;
|
||||
|
||||
/**
|
||||
* Marqueur de vérification de hach
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_checkHach = false;
|
||||
|
||||
/**
|
||||
* Liste des IPs des frontends (proxy)
|
||||
* @var array
|
||||
@ -37,20 +43,25 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
|
||||
* Authentification par WS
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param boolean $iponly
|
||||
* @param string $mode
|
||||
*/
|
||||
public function __construct($username, $password, $iponly = false)
|
||||
public function __construct($username, $password, $mode = null)
|
||||
{
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
if ($iponly){
|
||||
|
||||
if ($mode == 'hach') {
|
||||
$this->_checkHach = true;
|
||||
}
|
||||
|
||||
if ($mode == '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 = true;
|
||||
}
|
||||
$this->_checkIp = $iponly;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,14 +82,18 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
|
||||
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 ( $InfosLogin !== false && !empty($InfosLogin->result->login)) {
|
||||
}
|
||||
// --- Assignation identity
|
||||
elseif ( $InfosLogin !== false && !empty($InfosLogin->result->login)) {
|
||||
$identity = new stdClass();
|
||||
$identity->username = $InfosLogin->result->login;
|
||||
if ($this->_checkIp) {
|
||||
$identity->password = $this->_password;
|
||||
if ($this->_checkIp || $this->_checkHach) {
|
||||
Zend_Registry::get('firebug')->info("IN");
|
||||
$identity->password = $this->_password;
|
||||
} else {
|
||||
$identity->password = md5($InfosLogin->result->login.'|'.$this->_password);
|
||||
$identity->password = md5($InfosLogin->result->login.'|'.$this->_password);
|
||||
}
|
||||
Zend_Registry::get('firebug')->info($identity->password);
|
||||
$identity->username = $InfosLogin->result->login;
|
||||
$identity->email = $InfosLogin->result->email;
|
||||
$identity->profil = $InfosLogin->result->profil;
|
||||
$identity->pref = $InfosLogin->result->pref;
|
||||
|
Loading…
Reference in New Issue
Block a user