diff --git a/.gitattributes b/.gitattributes index 37e02777b118368f5a317f17be6dd79d27e3cd01..be7df1e6e118f8e1d39983ddda51afe6b3bbddb8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4897,6 +4897,7 @@ scripts/find_tests.php -text scripts/insert_licence.sh -text scripts/iosrd.sh -text scripts/marker-visit.el -text +scripts/md5base64.pl -text scripts/opac2.sql -text scripts/opac3.el -text scripts/org-link-minor-mode.el -text diff --git a/library/ZendAfi/Auth.php b/library/ZendAfi/Auth.php index 56b44e669971b6091d97ee1fd0c7c8ce47e21654..e75e30d278e60559614a2b6cdb2fb46cd9030f23 100644 --- a/library/ZendAfi/Auth.php +++ b/library/ZendAfi/Auth.php @@ -63,10 +63,16 @@ class ZendAfi_Auth extends Zend_Auth { $adapters = $this->getOrderedAdaptersForLoginPassword($login, $password); foreach ($adapters as $authAdapter) { + $authAdapter->setIdentity($login); $authAdapter->setCredential($password); - if (!$this->authenticate($authAdapter)->isValid()) continue; + if (!$this->authenticate($authAdapter)->isValid()) { + $authAdapter->setCredential($this->md5_base64($this->_credential)); + if (!$this->authenticate($authAdapter)->isValid()) +continue; + + } $this->getStorage()->write($authAdapter->getResultObject()); return true; } @@ -74,6 +80,12 @@ class ZendAfi_Auth extends Zend_Auth { } + public function md5_base64 ( $data ) + { + return preg_replace('/=+$/','',base64_encode(pack('H*',md5($data)))); + + } + public function logUser($user) { $this->getStorage()->write($user->toStdClass()); return $this; diff --git a/scripts/md5base64.pl b/scripts/md5base64.pl new file mode 100644 index 0000000000000000000000000000000000000000..cb944d44e6bd3fb2c635d1b8a9a3764a2117c94c --- /dev/null +++ b/scripts/md5base64.pl @@ -0,0 +1,5 @@ + +use Digest::MD5 +qw(md5_base64); +my $var='adminPassword'; +print md5_base64($var); diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 4d163aba40460c9e9c2def81bd83f5481b111fb9..79696c948f391ddfae6e521490c388e2bba1e28c 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -325,7 +325,7 @@ class AuthControllerAdminIsLoggedTest extends PortailWithOneLoginModuleTestCase ->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL) ->setRole('super_admin') ->setLogin('sysadm') - ->setPassword('pafgjl') + ->setPassword('sysadmPassword') ->setIdSite(1) ->setIdabon('') ->setId(1); @@ -415,7 +415,6 @@ class AuthControllerPostTest extends AuthControllerNobodyLoggedTestCase { - class AuthControllerPostSimpleTest extends AuthControllerNobodyLoggedTestCase { protected $_auth; @@ -460,4 +459,8 @@ class AuthControllerPostSimpleTest extends AuthControllerNobodyLoggedTestCase { } } + + + + ?> \ No newline at end of file diff --git a/tests/library/ZendAfi/AuthTest.php b/tests/library/ZendAfi/AuthTest.php index 7914c2472682e9b9fc16b858c5b3a1ac3952b67a..51395d9320445852644bec6472fc742a9b971a68 100644 --- a/tests/library/ZendAfi/AuthTest.php +++ b/tests/library/ZendAfi/AuthTest.php @@ -25,4 +25,42 @@ class AuthSessionNamespaceTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Zend_Auth' . md5(BASE_URL), ZendAfi_Auth::getInstance()->getStorage()->getNamespace()); } -} \ No newline at end of file + + + /** + * @test + */ + public function validAuthenticationInMd5ShouldRedirect() { + + $zendAuth = new ZendAfi_Auth(); + assertTrue($zendAuth->authenticateLoginPassword('sysadm','adminPassword',[new Mock_Adapter()])); + + } +} + + + +class Mock_Adapter implements Zend_Auth_Adapter_Interface { + public function setIdentity($identity) { + $this->_identity = $identity; + return $this; + } + + /** + * @param string $credential + * @return Zend_Auth_Adapter_CommSigb + */ + public function setCredential($credential) { + $this->_credential = $credential; + return $this; + } + + + + public function authenticate() { + if ($this->_credential == 'M9h/02RRb2YEEk/Mdv3SeQ') + return true; + + } +} +