@@ -16,8 +16,14 @@ passed as a query string parameter or via an HTTP header.
16
16
The API Key Authenticator
17
17
-------------------------
18
18
19
+ .. versionadded :: 2.8
20
+ The ``SimplePreAuthenticatorInterface `` interface was moved to the
21
+ ``Symfony\Component\Security\Http\Authentication`` namespace in Symfony
22
+ 2.8. Prior to 2.8, it was located in the
23
+ ``Symfony\Component\Security\Core\Authentication `` namespace.
24
+
19
25
Authenticating a user based on the Request information should be done via a
20
- pre-authentication mechanism. The :class: `Symfony\\ Component\\ Security\\ Core \\ Authentication\\ SimplePreAuthenticatorInterface `
26
+ pre-authentication mechanism. The :class: `Symfony\\ Component\\ Security\\ Http \\ Authentication\\ SimplePreAuthenticatorInterface `
21
27
allows you to implement such a scheme really easily.
22
28
23
29
Your exact situation may differ, but in this example, a token is read
@@ -27,13 +33,13 @@ value and then a User object is created::
27
33
// src/AppBundle/Security/ApiKeyAuthenticator.php
28
34
namespace AppBundle\Security;
29
35
30
- use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
36
+ use Symfony\Component\HttpFoundation\Request;
37
+ use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
31
38
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
32
39
use Symfony\Component\Security\Core\Exception\AuthenticationException;
33
- use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
34
- use Symfony\Component\HttpFoundation\Request;
35
- use Symfony\Component\Security\Core\User\UserProviderInterface;
36
40
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
41
+ use Symfony\Component\Security\Core\User\UserProviderInterface;
42
+ use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
37
43
38
44
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
39
45
{
@@ -273,9 +279,9 @@ you can use to create an error ``Response``.
273
279
// src/AppBundle/Security/ApiKeyAuthenticator.php
274
280
namespace AppBundle\Security;
275
281
276
- use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
277
282
use Symfony\Component\Security\Core\Exception\AuthenticationException;
278
283
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
284
+ use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
279
285
use Symfony\Component\HttpFoundation\Response;
280
286
use Symfony\Component\HttpFoundation\Request;
281
287
@@ -506,8 +512,8 @@ for security reasons. To take advantage of the session, update ``ApiKeyAuthentic
506
512
to see if the stored token has a valid User object that can be used::
507
513
508
514
// src/AppBundle/Security/ApiKeyAuthenticator.php
509
- // ...
510
515
516
+ // ...
511
517
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
512
518
{
513
519
// ...
0 commit comments