Commit e44cce3b authored by Fabien Potencier's avatar Fabien Potencier

fixed deprecations in SecurityServiceProvider tests

parent 52d38c55
...@@ -13,6 +13,7 @@ namespace Silex\Tests\Provider\SecurityServiceProviderTest; ...@@ -13,6 +13,7 @@ namespace Silex\Tests\Provider\SecurityServiceProviderTest;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
...@@ -27,7 +28,7 @@ class TokenAuthenticator extends AbstractGuardAuthenticator ...@@ -27,7 +28,7 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
public function getCredentials(Request $request) public function getCredentials(Request $request)
{ {
if (!$token = $request->headers->get('X-AUTH-TOKEN')) { if (!$token = $request->headers->get('X-AUTH-TOKEN')) {
return; return Kernel::VERSION_ID < 34000 ? null : false;
} }
list($username, $secret) = explode(':', $token); list($username, $secret) = explode(':', $token);
...@@ -38,6 +39,11 @@ class TokenAuthenticator extends AbstractGuardAuthenticator ...@@ -38,6 +39,11 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
]; ];
} }
public function supports(Request $request)
{
return !empty($request->headers->get('X-AUTH-TOKEN'));
}
public function getUser($credentials, UserProviderInterface $userProvider) public function getUser($credentials, UserProviderInterface $userProvider)
{ {
return $userProvider->loadUserByUsername($credentials['username']); return $userProvider->loadUserByUsername($credentials['username']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment