Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 26 changed files with 160 additions and 54 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
},
"require": {
"php": ">=5.3.3",
"php": ">=5.3.23",
"zendframework/zend-stdlib": "self.version"
},
"require-dev": {
Expand All @@ -39,8 +39,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2-dev",
"dev-develop": "2.3-dev"
"dev-master": "2.3-dev",
"dev-develop": "2.4-dev"
}
},
"autoload-dev": {
Expand Down
8 changes: 4 additions & 4 deletions src/Adapter/DbTable/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function __construct(
* setTableName() - set the table name to be used in the select query
*
* @param string $tableName
* @return DbTable Provides a fluent interface
* @return self Provides a fluent interface
*/
public function setTableName($tableName)
{
Expand All @@ -117,7 +117,7 @@ public function setTableName($tableName)
* setIdentityColumn() - set the column name to be used as the identity column
*
* @param string $identityColumn
* @return DbTable Provides a fluent interface
* @return self Provides a fluent interface
*/
public function setIdentityColumn($identityColumn)
{
Expand All @@ -129,7 +129,7 @@ public function setIdentityColumn($identityColumn)
* setCredentialColumn() - set the column name to be used as the credential column
*
* @param string $credentialColumn
* @return DbTable Provides a fluent interface
* @return self Provides a fluent interface
*/
public function setCredentialColumn($credentialColumn)
{
Expand All @@ -143,7 +143,7 @@ public function setCredentialColumn($credentialColumn)
* false) parameters. Default is false.
*
* @param int|bool $flag
* @return DbTable Provides a fluent interface
* @return self Provides a fluent interface
*/
public function setAmbiguityIdentity($flag)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/DbTable/CallbackCheckAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
* credential.
*
* @param callable $validationCallback
* @return DbTable
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setCredentialValidationCallback($validationCallback)
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/DbTable/CredentialTreatmentAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(
* 'MD5(?)'
*
* @param string $treatment
* @return DbTable Provides a fluent interface
* @return self Provides a fluent interface
*/
public function setCredentialTreatment($treatment)
{
Expand Down
41 changes: 29 additions & 12 deletions src/Adapter/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ public function authenticate()

$headers = $this->request->getHeaders();
if (!$headers->has($getHeader)) {
return $this->_challengeClient();
return $this->challengeClient();
}
$authHeader = $headers->get($getHeader)->getFieldValue();
if (!$authHeader) {
return $this->_challengeClient();
return $this->challengeClient();
}

list($clientScheme) = explode(' ', $authHeader);
Expand All @@ -360,7 +360,7 @@ public function authenticate()
// client sent a scheme that is not the one required
if (!in_array($clientScheme, $this->acceptSchemes)) {
// challenge again the client
return $this->_challengeClient();
return $this->challengeClient();
}

switch ($clientScheme) {
Expand All @@ -377,6 +377,23 @@ public function authenticate()
return $result;
}

/**
* @deprecated
* @see Http::challengeClient()
* @return Authentication\Result Always returns a non-identity Auth result
*/
protected function _challengeClient()
{
trigger_error(sprintf(
'The method "%s" is deprecated and will be removed in the future; '
. 'please use the public method "%s::challengeClient()" instead',
__METHOD__,
__CLASS__
), E_USER_DEPRECATED);

return $this->challengeClient();
}

/**
* Challenge Client
*
Expand All @@ -385,7 +402,7 @@ public function authenticate()
*
* @return Authentication\Result Always returns a non-identity Auth result
*/
protected function _challengeClient()
public function challengeClient()
{
if ($this->imaProxy) {
$statusCode = 407;
Expand Down Expand Up @@ -474,12 +491,12 @@ protected function _basicAuth($header)
// implementation does. If invalid credentials are detected,
// re-challenge the client.
if (!ctype_print($auth)) {
return $this->_challengeClient();
return $this->challengeClient();
}
// Fix for ZF-1515: Now re-challenges on empty username or password
$creds = array_filter(explode(':', $auth));
if (count($creds) != 2) {
return $this->_challengeClient();
return $this->challengeClient();
}

$result = $this->basicResolver->resolve($creds[0], $this->realm, $creds[1]);
Expand All @@ -498,7 +515,7 @@ protected function _basicAuth($header)
return new Authentication\Result(Authentication\Result::SUCCESS, $result);
}

return $this->_challengeClient();
return $this->challengeClient();
}

/**
Expand Down Expand Up @@ -530,17 +547,17 @@ protected function _digestAuth($header)
// See ZF-1052. This code was a bit too unforgiving of invalid
// usernames. Now, if the username is bad, we re-challenge the client.
if ('::invalid::' == $data['username']) {
return $this->_challengeClient();
return $this->challengeClient();
}

// Verify that the client sent back the same nonce
if ($this->_calcNonce() != $data['nonce']) {
return $this->_challengeClient();
return $this->challengeClient();
}
// The opaque value is also required to match, but of course IE doesn't
// play ball.
if (!$this->ieNoOpaque && $this->_calcOpaque() != $data['opaque']) {
return $this->_challengeClient();
return $this->challengeClient();
}

// Look up the user's password hash. If not found, deny access.
Expand All @@ -549,7 +566,7 @@ protected function _digestAuth($header)
// to be recreatable with the current settings of this object.
$ha1 = $this->digestResolver->resolve($data['username'], $data['realm']);
if ($ha1 === false) {
return $this->_challengeClient();
return $this->challengeClient();
}

// If MD5-sess is used, a1 value is made of the user's password
Expand Down Expand Up @@ -588,7 +605,7 @@ protected function _digestAuth($header)
return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
}

return $this->_challengeClient();
return $this->challengeClient();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Http/ApacheResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($path = '')
* Set the path to the credentials file
*
* @param string $path
* @return FileResolver Provides a fluent interface
* @return self Provides a fluent interface
* @throws Exception\InvalidArgumentException if path is not readable
*/
public function setFile($path)
Expand Down
2 changes: 1 addition & 1 deletion src/AuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Zend\Authentication;

class AuthenticationService
class AuthenticationService implements AuthenticationServiceInterface
{
/**
* Persistent storage handler
Expand Down
44 changes: 44 additions & 0 deletions src/AuthenticationServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Authentication;

/**
* Provides an API for authentication and identity management
*/
interface AuthenticationServiceInterface
{
/**
* Authenticates and provides an authentication result
*
* @return Result
*/
public function authenticate();

/**
* Returns true if and only if an identity is available
*
* @return bool
*/
public function hasIdentity();

/**
* Returns the authenticated identity or null if no identity is available
*
* @return mixed|null
*/
public function getIdentity();

/**
* Clears the identity
*
* @return void
*/
public function clearIdentity();
}
2 changes: 1 addition & 1 deletion test/Adapter/DbTable/CallbackCheckAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Adapter/DbTable/CredentialTreatmentAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Adapter/DbTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Adapter/DigestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
9 changes: 1 addition & 8 deletions test/Adapter/Http/ApacheResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -38,13 +38,6 @@ class ApacheResolverTest extends \PHPUnit_Framework_TestCase
*/
protected $_badPath;

/**
* Resolver instance
*
* @var Zend_Auth_Adapter_Http_Resolver_File
*/
protected $_resolver;

/**
* Sets the paths to files used in this test, and creates a shared resolver instance
* having a valid path.
Expand Down
4 changes: 2 additions & 2 deletions test/Adapter/Http/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -57,7 +57,7 @@ class AuthTest extends \PHPUnit_Framework_TestCase
/**
* File resolver setup against with HTTP Digest auth file
*
* @var Zend_Auth_Adapter_Http_Resolver_File
* @var Http\FileResolver
*/
protected $_digestResolver;

Expand Down
4 changes: 2 additions & 2 deletions test/Adapter/Http/FileResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -40,7 +40,7 @@ class FileResolverTest extends \PHPUnit_Framework_TestCase
/**
* Resolver instance
*
* @var Zend_Auth_Adapter_Http_Resolver_File
* @var Http\FileResolver
*/
protected $_resolver;

Expand Down
2 changes: 1 addition & 1 deletion test/Adapter/Http/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
Loading

0 comments on commit 84412c5

Please sign in to comment.