Skip to content

Instantly share code, notes, and snippets.

@romaricdrigon
Last active January 17, 2020 13:36
Show Gist options
  • Save romaricdrigon/5c6f438afb2715357464d06241addf03 to your computer and use it in GitHub Desktop.
Save romaricdrigon/5c6f438afb2715357464d06241addf03 to your computer and use it in GitHub Desktop.
Commented Symfony Guard
<?php
namespace Symfony\Component\Security\Guard\Firewall;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
interface AuthenticatorInterface extends AuthenticatorInterface
{
// Can I try to read authentication data from this request?
// Return true / false (end of the process)
public function supports(Request $request);
// Read authentication data from the request.
// Return it [mixed] or null (failure). Typically we return an array with username and password.
public function getCredentials(Request $request);
// Fetch an User from given username, from User provider.
// Return it (UserInterface) or null (failure)
public function getUser($credentials, UserProviderInterface $userProvider);
// Check credentials versus User, typically we compare password.
// Returns true if good, anything else will cause authentication failure
public function checkCredentials($credentials, UserInterface $user);
// Called when one of the previous methods failed.
// Return Response to the user (ie., RedirectResponse to login or a 403)
// Return null for silent failure (user is not authenticated)
public function onAuthenticationFailure(Request $request, AuthenticationException $exception);
// Called when authentication suceeded.
// Return Response to the user (ie., RedirectResponse to admin or previous page)
// Return null for silent success (user stays on the same page)
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey);
// Return true to indicate it supports remmember me cookies
public function supportsRememberMe();
// Inherited from AuthenticationEntryPointInterface: handles an unconnected user (ie., redirect or 401)
public function start(Request $request, AuthenticationException $authException = null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment