diff --git a/cookbook/security/api_key_authentication.rst b/cookbook/security/api_key_authentication.rst index da7de4f8502..18027be259f 100644 --- a/cookbook/security/api_key_authentication.rst +++ b/cookbook/security/api_key_authentication.rst @@ -16,8 +16,14 @@ passed as a query string parameter or via an HTTP header. The API Key Authenticator ------------------------- +.. versionadded:: 2.8 + The ``SimplePreAuthenticatorInterface`` interface was moved to the + ``Symfony\Component\Security\Http\Authentication`` namespace in Symfony + 2.8. Prior to 2.8, it was located in the + ``Symfony\Component\Security\Core\Authentication`` namespace. + Authenticating a user based on the Request information should be done via a -pre-authentication mechanism. The :class:`Symfony\\Component\\Security\\Core\\Authentication\\SimplePreAuthenticatorInterface` +pre-authentication mechanism. The :class:`Symfony\\Component\\Security\\Http\\Authentication\\SimplePreAuthenticatorInterface` allows you to implement such a scheme really easily. 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:: // src/AppBundle/Security/ApiKeyAuthenticator.php namespace AppBundle\Security; - use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface; + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; - use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken; - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\Exception\BadCredentialsException; + use Symfony\Component\Security\Core\User\UserProviderInterface; + use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface; class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface { @@ -273,9 +279,9 @@ you can use to create an error ``Response``. // src/AppBundle/Security/ApiKeyAuthenticator.php namespace AppBundle\Security; - use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; + use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; @@ -506,8 +512,8 @@ for security reasons. To take advantage of the session, update ``ApiKeyAuthentic to see if the stored token has a valid User object that can be used:: // src/AppBundle/Security/ApiKeyAuthenticator.php - // ... + // ... class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface { // ... diff --git a/cookbook/security/custom_password_authenticator.rst b/cookbook/security/custom_password_authenticator.rst index c71995b7402..ca1f02775a2 100644 --- a/cookbook/security/custom_password_authenticator.rst +++ b/cookbook/security/custom_password_authenticator.rst @@ -21,8 +21,14 @@ The Password Authenticator .. versionadded:: 2.6 The ``UserPasswordEncoderInterface`` interface was introduced in Symfony 2.6. +.. versionadded:: 2.8 + The ``SimpleFormAuthenticatorInterface`` interface was moved to the + ``Symfony\Component\Security\Http\Authentication`` namespace in Symfony + 2.8. Prior to 2.8, it was located in the + ``Symfony\Component\Security\Core\Authentication`` namespace. + First, create a new class that implements -:class:`Symfony\\Component\\Security\\Core\\Authentication\\SimpleFormAuthenticatorInterface`. +:class:`Symfony\\Component\\Security\\Http\\Authentication\\SimpleFormAuthenticatorInterface`. Eventually, this will allow you to create custom logic for authenticating the user:: @@ -30,13 +36,13 @@ the user:: namespace Acme\HelloBundle\Security; use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\User\UserProviderInterface; + use Symfony\Component\Security\Http\Authentication\SimpleFormAuthenticatorInterface; class TimeAuthenticator implements SimpleFormAuthenticatorInterface {