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

2022-01-04 00:00:00 php yii hybridauth hybridauthprovider

我正在尝试使用 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 并且我在 index.php 文件的顶部包含了 Hybrid/Auth.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 的混合身份验证登录需要一个有效的域,而不是本地主机.

  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

相关文章