Skip to content

Commit 4036d26

Browse files
committed
Use new Simple{Form,Pre}AuthenticatorInterface namespaces
1 parent 3ebf2d0 commit 4036d26

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

cookbook/security/api_key_authentication.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ passed as a query string parameter or via an HTTP header.
1616
The API Key Authenticator
1717
-------------------------
1818

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+
1925
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`
2127
allows you to implement such a scheme really easily.
2228

2329
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::
2733
// src/AppBundle/Security/ApiKeyAuthenticator.php
2834
namespace AppBundle\Security;
2935

30-
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
36+
use Symfony\Component\HttpFoundation\Request;
37+
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
3138
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
3239
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;
3640
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
41+
use Symfony\Component\Security\Core\User\UserProviderInterface;
42+
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
3743

3844
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
3945
{
@@ -273,9 +279,9 @@ you can use to create an error ``Response``.
273279
// src/AppBundle/Security/ApiKeyAuthenticator.php
274280
namespace AppBundle\Security;
275281
276-
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
277282
use Symfony\Component\Security\Core\Exception\AuthenticationException;
278283
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
284+
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
279285
use Symfony\Component\HttpFoundation\Response;
280286
use Symfony\Component\HttpFoundation\Request;
281287
@@ -506,8 +512,8 @@ for security reasons. To take advantage of the session, update ``ApiKeyAuthentic
506512
to see if the stored token has a valid User object that can be used::
507513

508514
// src/AppBundle/Security/ApiKeyAuthenticator.php
509-
// ...
510515

516+
// ...
511517
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
512518
{
513519
// ...

cookbook/security/custom_password_authenticator.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ The Password Authenticator
2121
.. versionadded:: 2.6
2222
The ``UserPasswordEncoderInterface`` interface was introduced in Symfony 2.6.
2323

24+
.. versionadded:: 2.8
25+
The ``SimpleFormAuthenticatorInterface`` interface was moved to the
26+
``Symfony\Component\Security\Http\Authentication`` namespace in Symfony
27+
2.8. Prior to 2.8, it was located in the
28+
``Symfony\Component\Security\Core\Authentication`` namespace.
29+
2430
First, create a new class that implements
25-
:class:`Symfony\\Component\\Security\\Core\\Authentication\\SimpleFormAuthenticatorInterface`.
31+
:class:`Symfony\\Component\\Security\\Http\\Authentication\\SimpleFormAuthenticatorInterface`.
2632
Eventually, this will allow you to create custom logic for authenticating
2733
the user::
2834

2935
// src/Acme/HelloBundle/Security/TimeAuthenticator.php
3036
namespace Acme\HelloBundle\Security;
3137

3238
use Symfony\Component\HttpFoundation\Request;
33-
use Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface;
3439
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
3540
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
3641
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
3742
use Symfony\Component\Security\Core\Exception\AuthenticationException;
3843
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
3944
use Symfony\Component\Security\Core\User\UserProviderInterface;
45+
use Symfony\Component\Security\Http\Authentication\SimpleFormAuthenticatorInterface;
4046

4147
class TimeAuthenticator implements SimpleFormAuthenticatorInterface
4248
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy