Symfony2赢得';t加载自定义身份验证提供程序,加载DaoAuthenticationProvider


Symfony2 won't load custom authentication provider, loads DaoAuthenticationProvider

这是我最后一个问题的延续

你好,

我正在Symfony2应用程序中实现一个自定义身份验证提供程序,以便根据Wordnik REST API进行身份验证。

在应用程序加载时,无论请求路径如何,我都会遇到以下异常:

( ! ) Fatal error: Cannot access parent:: when current class scope has no parent in /[..]/WordRot/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php on line 43

你可以在这里看到完整的堆叠比赛。

跟踪中倒数第二行显示它正在加载DaoAuthenticationProvider:

18 0.0217 1922792 Symfony'Component'Security'Core'Authentication'Provider'DaoAuthenticationProvider->__construct( ) ../appDevDebugProjectContainer.php:3071

但是我的配置没有引用那个提供程序,也没有任何扩展它的东西。我的自定义提供程序直接实现了AuthenticationProviderInterface

所以我认为我的配置是错误的,我需要在某个地方显式地设置WordnikProvider,但我不确定在哪里!研究没有为这个问题提供任何线索。

任何帮助都将不胜感激!

文件

  • /app/config/config.yml
  • /app/config/security.yml
  • /src/WordRot/PlayBundle/Security/Authentication/Provider/WordnikProvider.php
  • /src/WordRot/PlayBundle/Security/Authentication/Token/WordnikUserToken.php
  • /src/WordRot/PlayBundle/Security/Firewall/WordnikListener.php
  • /src/WordRot/PlayBundle/DependencyInjection/Security/Factory/WordnikFactory.php

行返回$this->authenticationManager->authenticate(new WordnikUserToken($username,$password,$this->providerKey));在WordnikListener转到Symfony''Component''Security''Core''Authentication''Authentication ProviderManager(classes.php)证明…是真实的$this->提供程序包括DaoAuthentificationProvider、WordnikProvider和AnonymousAuthentificationProvider。从DaoAuthentificationProvider,它只使用支持的方法($token):return$token instanceofUsernamePasswordToken&amp$this->providerKey===$token->getProviderKey();

返回false,所以下一行是WordnikProvider。

哦。。误读:错误在构造函数中:parent::__construct($userChecker、$providerKey、$hideUserNotFoundExceptions);似乎失败了。运行PHP 5.4.10左右我没有错误!!

请rm-rf供应商重新运行composer安装,或者尝试使用不同的PHP版本!!

A一周前不得不创建这样的东西。在和中,我创建了一个自定义用户提供程序,在那里我只需调用api,并使用响应创建用户或不创建用户。

我建议阅读以下内容:

http://symfony.com/doc/2.0/cookbook/security/custom_provider.html