我想了解HWIOauthBUndle的工作原理。我可以看到如何构建和建立对资源所有者的初始授权请求。
但是,我没有看到,资源所有者的回调如何触发我的应用程序中的任何控制器/操作(尽管如此)。
当遵循通常可用的说明时,将回调<path to my app>/check-[resourceOwner]
之类的内容,例如http://www.example.com/oauth/check-facebook
。
在我的routing.yml
文件中,我放了
facebook_login:
pattern: /oauth/check-facebook
我不知道任何控制器如何与该路由相关联,那么在对我的应用程序进行回调时会发生什么?
答案 0 :(得分:0)
身份验证提供程序系统是更复杂的功能之一。您可能希望在此处阅读:http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html
回调是通过请求侦听器处理的。具体做法是:
namespace HWI\Bundle\OAuthBundle\Security\Http\Firewall\OAuthListener;
use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener;
class OAuthListener extends AbstractAuthenticationListener
{
public function requiresAuthentication(Request $request)
{
// Check if the route matches one of the check paths
foreach ($this->checkPaths as $checkPath) {
if ($this->httpUtils->checkRequestPath($request, $checkPath)) {
return true;
}
}
return false;
}
protected function attemptAuthentication(Request $request)
{
// Lots of good stuff here
如何初始化checkPaths以及如何进行所有调用将需要很长的解释。但是身份验证提供程序章节将帮助您。