Symfony2中不会加载自定义身份验证提供者,负载需要把DaoAuthenticationProvider [英] Symfony2 won't load custom authentication provider, loads DaoAuthenticationProvider

查看:471
本文介绍了Symfony2中不会加载自定义身份验证提供者,负载需要把DaoAuthenticationProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我为了反对Wordnik REST API认证正在实现,在Symfony2中的应用程序,自定义身份验证提供者。

I'm implementing, in a Symfony2 application, a custom authentication provider in order to authenticate against the Wordnik REST API.

在应用负载,不管是什么请求路径,这是例外,我得到:

On application load, no matter what request path, this is the exception I get:

致命错误(!):当电流类范围在没有父无法访问父:: /[..]/WordRot/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php在线43

您可以看到完整的堆栈跟踪这里

You can see the full stacktrace here.

二来在跟踪最后一行显示,它加载的是 DaoAuthenticationProvider的时候

Second to last line in the trace reveals that it is loading the DaoAuthenticationProvider:

18 0.0217 1922792的Symfony \\分量\\安全\\核心\\认证\\供应商\\ DaoAuthenticationProvider-> __构造()../ appDevDebugProjectContainer.php:3071

但没有我的配置是指供应商,或任何其扩展。我的自定义提供直接实现 AuthenticationProviderInterface

But none of my configuration refers to that provider, or anything that extends it. My custom provider directly implements the AuthenticationProviderInterface.

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

So I assume that my configuration is wrong, and somewhere I need to be explicitly setting the WordnikProvider, but I'm not sure where! Research has not provided any clues to this issue.

任何帮助将是非常美联社preciated!

Any help would be much appreciated!

文件

  • /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

推荐答案

行返回$这个 - > authenticationManager->认证(新WordnikUserToken($的用户名,密码$,$这个 - > providerKey));在WordnikListener去
Symfony的\\分量\\安全\\核心\\认证\\ AuthenticationProviderManager(classes.php)
认证。
$这个 - >提供商DaoAuthentificationProvider,WordnikProvider和AnonymousAuthentificationProvider。
从DaoAuthentificationProvider它仅使用此方法支持($令牌):
返回$令牌的instanceof UsernamePasswordToken&放大器;&安培; $这个 - > providerKey === $ token-> getProviderKey();

the line return $this->authenticationManager->authenticate(new WordnikUserToken($username, $password, $this->providerKey)); in the WordnikListener goes to Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager (classes.php) authenticate. $this->providers are DaoAuthentificationProvider, WordnikProvider and AnonymousAuthentificationProvider. From the DaoAuthentificationProvider it only uses the method supports($token): return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey();

返回的行false,所以接下来就是WordnikProvider。

which returns false so next in line is WordnikProvider.

Oh..misread:错误是在构造函数:
父:: __构造($ userChecker,$ providerKey,$ hideUserNotFoundExceptions);似乎失败。运行PHP 5.4.10还是让我没有错误!

Oh..misread: the error is in the constructor: parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); seems to fail. Running PHP 5.4.10 or so I DON'T have an error!!

无论室射频供应商和运行作曲家重新安装或尝试使用不同的PHP版本!

Either rm -rf vendor and run composer install again or try using a different PHP version!!

这篇关于Symfony2中不会加载自定义身份验证提供者,负载需要把DaoAuthenticationProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆