FOSOAuthServerBundle icon indicating copy to clipboard operation
FOSOAuthServerBundle copied to clipboard

Setting `services.user_provider` does not work if `service.storage` is set too

Open arnaud-lb opened this issue 9 years ago • 1 comments

Setting both services.user_provider and services.user_provider configuration throws the following exception:

  [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
  The service definition "oauth_server.server_service.storage" does not exist.

Exception trace:
 () at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:798
 Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() at vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/DependencyInjection/FOSOAuthServerExtension.php:79

With this configuration:

fos_oauth_server:
    service:
        user_provider:        fos_user.user_manager
        storage:              oauth_server.server_service.storage

On Symfony 2.3.

The problem seems to be that FOSOAuthServerExtension tries to override a parameter of the storage service during load(), however the service doesn't exist yet at this point: https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/cbe6c77a873950240ebd86573610f69c943da629/DependencyInjection/FOSOAuthServerExtension.php#L47

Also, it seems that the user_provider is optional, and that the OAuthStorage class allows a null $userProvider too; however it seems to be always required at runtime.

arnaud-lb avatar Dec 15 '15 13:12 arnaud-lb

Same here, A workaround for this is to set an alias for Symfony\Component\Security\Core\User\UserProviderInterface

    Symfony\Component\Security\Core\User\UserProviderInterface:
        alias: fos_user.user_provider.username_email

andrzej-tracz avatar Feb 27 '20 09:02 andrzej-tracz