与Yii的混合身份验证导致重定向循环

与Yii的混合身份验证导致重定向循环

本文介绍了与Yii的混合身份验证导致重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用hybridauth在我的网站上实现Twitter登录.我知道Yii有一个混合身份验证插件.我没有使用它,因为上次使用时遇到了一些问题.我正在尝试实现混合身份验证的核心版本.

I am trying to implement twitter sign in on my website using hybridauth.I know there is a hybrid auth plugin for Yii. I am not using it because last time I used I ran into some problems. I am trying to implement the core version of hybrid auth.

我在打电话

$hybridauth = new Hybrid_Auth( Yii::app()->params['hybridauth'] );
$adapter = $hybridauth->authenticate( 'Twitter');

但是由于某种原因,它会重定向到http://localhost/yiiauth/authtest/?hauth.start=Twitter&hauth.time=1350973441,这会导致重定向循环.有什么办法解决这个问题?我的混合身份验证配置如下:

But for some reason it redirects to http://localhost/yiiauth/authtest/?hauth.start=Twitter&hauth.time=1350973441 , which causes a redirect loop.Is there any way to solve this problem ? My hybrid auth configuration is as follows :

'params'=>array(

    'hybridauth'=>array(
        "base_url" => "http://localhost/yiiauth/authtest/",

        "providers" => array (
            "Twitter" => array (
                "enabled" => true,
                "keys"    => array ( "key" => "mykey", "secret" => "mysecret" )
            ),
        ),


        "debug_mode" => false,

        "debug_file" => "",
    )
),

我的hybridauth文件位于/protected/extensions/hybridauth中,而Hybrid/Auth.php位于index.php文件的顶部

My hybridauth files are in /protected/extensions/hybridauth and I include the Hybrid/Auth.php in the top of the index.php file

推荐答案

  1. 用于Twitter和Facebook的混合身份验证登录需要有效域而不是localhost.

  1. Hybrid Auth login for twitter and facebook requires a valid domain not localhost.

您在配置文件"hybridauth.php"中的 base_url 应设置为"/hauth/endpoint",即它必须指向端点.如果您已通过.htaccess删除了index.php,请使用"/index.php/hauth/endpoint".

Your base_url in configuration file "hybridauth.php" should be set to "/hauth/endpoint" i.e. it must point to the endpoint. If you have removed index.php through .htaccess then use "/index.php/hauth/endpoint".

在Logs文件夹中将hybridauth.log的权限设置为可写.

Set permissions of hybridauth.log in Logs folder to writable.

参考链接: http://hybridauth.sourceforge.net/userguide/Configuration.html

这篇关于与Yii的混合身份验证导致重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:58