The reason of this question was born from a collaborator's request: I want to know if I can remove the provider. Is mandatory? I want to remove it if I can leave its methods empty.
So, in Symfony providers configuration is mandatory. Also i need to configure at least one Provider. Done! My custom providere is this:
final class CustomListener implements UserProviderInterface
{
public function loadUserByUsername($username)
{
// ...
}
public function refreshUser(UserInterface $user)
{
return $user;
}
public function supportsClass($class)
{
// ...
}
}
I can login. Logout. ... but I am a bit confused. Why an interface want these "useless", at the moment, loadUserByUSername
and supportsClass
? Useless in the meaning of: I have empty implementation, and it works!!! Work, means that I set session manually with $request->getSession()->set('firefall', $token);
and user is authenticated. I can logout users invalidating session.
I am sure that at least, this provider NEEDS that refreshUser return a UserInterface:
public function refreshUser(UserInterface $user)
{
return $user;
}
Because login does not work without this return. But I can leave other methods empty.
I've looked inside tests and in UserProviderInterface
method's comments. But nothing. I didnt get if I can:
- remove provider;
- I am missing something in the documentation;
- I am trying to badly use Symfony (it is possible);
- I am a Teapot;
- ... -
And, .... Why login does not work when I comment this line even if My firewall does not use this provider?
public function refreshUser(UserInterface $user)
{
// return $user;
}
--
I've created this CustomListener
just because I've defined
a service as provider. Then I've received this message:
Argument 1 passed to Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider::__construct() must be an instance of Symfony\Component\Security\Core\User\UserProviderInterface,