Reputation: 1077
I'm reading up on Symfony's way of managing users through the custom User Provider: https://symfony.com/doc/current/security/custom_provider.html
When a user submits a username and password, the authentication layer asks the configured user provider to return a user object for a given username. Symfony then checks whether the password of this user is correct and generates a security token
This works great when we're connecting to a database with user/password locally, but I want to authenticate against another service. Basically, I want to use Symfony as a client that consumes the user login service. This is how I would do it, except I don't have access to the password here.
public function loadUserByUsername($username)
{
$client = new Client(['base_uri' => $uri]);
$user_response = $client->get('api/v1/getTokens/', ['auth' => [$username, <passord>]);
// $user_response
}
And this is much different from what Symfony expects, which is to receive a user object and then issue it's own Tokens if the user/password match.
Should I forgo the whole Custom Provider interface for my own system?
Upvotes: 0
Views: 1323
Reputation: 29932
You need an AuthenticationProvider to use in tandem with UserProvider you wrote.
Check also Guard Authentication
Upvotes: 0