8000 minor #7065 Fix Authenticator Class (getCredentials) example (thtroyer) · symfony/symfony-docs@8194fb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8194fb2

Browse files
committed
minor #7065 Fix Authenticator Class (getCredentials) example (thtroyer)
This PR was submitted for the 3.1 branch but it was merged into the 2.8 branch instead (closes #7065). Discussion ---------- Fix Authenticator Class (getCredentials) example The current wording surrounding the getCredentials is misleading. Returning null does stop authentication, but it causes authentication to be successful. The example implies that X-AUTH-TOKEN is required and should be correct. For this behavior, either an AuthenticationException should be thrown or the credential variables should be initialized as empty and passed on to getUser(). Commits ------- 52d56f4 Fix Authenticator Class (getCredentials) example
2 parents 54b2054 + 52d56f4 commit 8194fb2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

security/guard_authentication.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,15 @@ This requires you to implement six methods::
165165
class TokenAuthenticator extends AbstractGuardAuthenticator
166166
{
167167
/**
168-
* Called on every request. Return whatever credentials you want,
169-
* or null to stop authentication.
168+
* Called on every request. Return whatever credentials you want to
169+
* be passed to getUser(). Returning null will cause this authenticator
170+
* to be skipped.
170171
*/
171172
public function getCredentials(Request $request)
172173
{
173174
if (!$token = $request->headers->get('X-AUTH-TOKEN')) {
174-
// no token? Return null and no other methods will be called
175-
return;
175+
// No token?
176+
$token = null;
176177
}
177178

178179
// What you return here will be passed to getUser() as $credentials

0 commit comments

Comments
 (0)
0