Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 572bf3b

Browse filesBrowse files
committed
feature symfony#4800 [Cookbook][Security] Hint about createToken can return null (xelaris)
This PR was merged into the 2.5 branch. Discussion ---------- [Cookbook][Security] Hint about createToken can return null | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.5+ | Fixed tickets | see symfony/symfony#12002 Commits ------- 528aa17 [Cookbook][Security] Hint about createToken can return null
2 parents 4143076 + 528aa17 commit 572bf3b
Copy full SHA for 572bf3b

File tree

Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed

‎cookbook/security/api_key_authentication.rst

Copy file name to clipboardExpand all lines: cookbook/security/api_key_authentication.rst
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ value and then a User object is created::
5252

5353
if (!$apiKey) {
5454
throw new BadCredentialsException('No API key found');
55+
56+
// or to just skip api key authentication
57+
// return null;
5558
}
5659

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

108113
2. supportsToken
109114
~~~~~~~~~~~~~~~~

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.