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 9e411fe

Browse filesBrowse files
committed
I'm extending the abstract class - so mention that. Also adding anonymous
You probably want anonymous, because without it, if you return null so that the listener does nothing, you'll get an exception from the AccessListener. This article is written more where you don't *force* auth in the authenticator, but then if a resource is protected, it of course requires it.
1 parent ac107c7 commit 9e411fe
Copy full SHA for 9e411fe

File tree

1 file changed

+6
-2
lines changed
Filter options

1 file changed

+6
-2
lines changed

‎cookbook/security/guard-api-key.rst

Copy file name to clipboardExpand all lines: cookbook/security/guard-api-key.rst
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ A) Create the Guard Authenticator
2020
---------------------------------
2121

2222
Suppose you want to read an ``X-API-TOKEN`` header on each request and use
23-
that to authenticate the user. To do this, create a class that implements
24-
:class:`Symfony\\Component\\Security\\Guard\\\GuardAuthenticatorInterface`::
23+
that to authenticate the user. To do this, create a class that extends
24+
:class:`Symfony\\Component\\Security\\Guard\\AbstractGuardAuthenticator`
25+
(or which implements :class:`Symfony\\Component\\Security\\Guard\\GuardAuthenticatorInterface`)::
2526

2627
// src/AppBundle/Security/TokenAuthenticator.php
2728
namespace AppBundle\Security;
@@ -199,6 +200,7 @@ and your new ``app.token_authenticator`` authenticator:
199200
pattern: ^/
200201
# set to false if you *do* want to store users in the session
201202
stateless: true
203+
anonymous: true
202204
guard:
203205
authenticators:
204206
- app.token_authenticator
@@ -218,6 +220,7 @@ and your new ``app.token_authenticator`` authenticator:
218220
<firewall name="secured_area"
219221
pattern="^/"
220222
stateless="true"
223+
anonymous="true"
221224
>
222225
<guard>
223226
<authenticator>apikey_authenticator</authenticator>
@@ -237,6 +240,7 @@ and your new ``app.token_authenticator`` authenticator:
237240
'secured_area' => array(
238241
'pattern' => '^/',
239242
'stateless' => true,
243+
'anonymous' => true,
240244
'simple_preauth' => array(
241245
'authenticators' => array(
242246
'app.token_authenticator'

0 commit comments

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