Skip to content

Commit

Permalink
recommendations by xabbuh
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hudson authored and Sam Hudson committed Mar 9, 2014
1 parent 3366dfc commit db8e01a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
11 changes: 7 additions & 4 deletions cookbook/security/api_key_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,20 @@ exception in ``refreshUser()``.
Handling Authentication Failure
-------------------------------

In order for your ``ApiKeyAuthentication`` to correctly display a 403
http status when either bad credentials, or authentication fails - you will
need to implement the ``AuthenticationFailureHandlerInterface`` on your
In order for you're ``ApiKeyAuthentication`` to correctly display a 403
http status when either bad credentials or authentication fails you will
need to implement the :class:`Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface` on your
Authenticator. This will provide a method ``onAuthenticationFailure`` which
you can then return a ``Response`` with.
you can use to create an error ``Response``.

// src/Acme/HelloBundle/Security/ApiKeyAuthenticator.php
namespace Acme\HelloBundle\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\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;

class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface
{
Expand Down

0 comments on commit db8e01a

Please sign in to comment.