8000 Fix Authenticator Class (getCredentials) example by thtroyer · Pull Request #7065 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions security/guard_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ This requires you to implement six methods::
class TokenAuthenticator extends AbstractGuardAuthenticator
{
/**
* Called on every request. Return whatever credentials you want,
* or null to stop authentication.
* Called on every request. Return whatever credentials you want to
* be passed to getUser(). Returning null will cause this authenticator
* to be skipped.
*/
public function getCredentials(Request $request)
{
if (!$token = $request->headers->get('X-AUTH-TOKEN')) {
// no token? Return null and no other methods will be called
return;
// No token?
$token = null;
}

// What you return here will be passed to getUser() as $credentials
Expand Down
0