Skip to content

Commit

Permalink
[Cookbook][Security] Hint about createToken can return null
Browse files Browse the repository at this point in the history
  • Loading branch information
xelaris committed Jan 9, 2015
1 parent 1f343b1 commit 528aa17
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cookbook/security/api_key_authentication.rst
Expand Up @@ -52,6 +52,9 @@ value and then a User object is created::

if (!$apiKey) {
throw new BadCredentialsException('No API key found');

// or to just skip api key authentication
// return null;
}

return new PreAuthenticatedToken(
Expand Down Expand Up @@ -103,7 +106,9 @@ is to create a token object that contains all of the information from the
request that you need to authenticate the user (e.g. the ``apikey`` query
parameter). If that information is missing, throwing a
:class:`Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException`
will cause authentication to fail.
will cause authentication to fail. You might want to return ``null`` instead
to just skip the authentication, so Symfony can fallback to another authentication
method, if any.

2. supportsToken
~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 528aa17

Please sign in to comment.