【问题标题】:User management hybrid auth setup用户管理混合身份验证设置
【发布时间】:2014-01-13 21:45:38
【问题描述】:

我正在尝试在 Yii 用户管理插件上设置混合身份验证,文档在这里https://github.com/thyseus/yii-user-management/blob/master/user/docs/hybridauth.txt

按照这一步

Take the modules/user/vendors/index.php, rename it to 'hybridauth.php' and place it 
    beside your application index.php bootstrap script. This will be your hybrid auth
    entry script. 

为此,modules/user/vendors/index.php 中没有 index.php 文件,但modules/user/vendors/hybridauth/index.php 中有一个,我将其重命名为 hybridauth.php 并将其放入 http://localhost/dev/ 的 hybridauth.php 内容中

require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Auth.php" );

require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php" ); 

Hybrid_Endpoint::process();

现在开始

Place the hybrid auth configuration file into your application
protected/config/hybridauth.php. 

我将modules/user/vendors/hybridauth/config.php 放入protected/config/ 并将config.php 重命名为hybridauth.php。内容是这样的

return 
    array(
        "base_url" => Yii::app()->createAbsoluteUrl('/').'/hybridauth.php',
        "providers" => array ( 
            
...........
            "Google" => array ( 
                "enabled" => true,
                "keys"    => array (  
                            "id" => "ID", 
                            "secret" => "SECRET",
                        ), 
            ),

            "Facebook" => array ( 
                "enabled" => true,
                "keys"    => array ( 
                        "id" => "ID", 
                        "secret" => "SECRET",
                ), 
                "scope" => "email,user_birthday" // https://developers.facebook.com/docs/reference/login/
            ),
        ),

        // if you want to enable logging, set 'debug_mode' to true  then provide a writable file by the web server on "debug_file"
        "debug_mode" => false,

        "debug_file" => "",
    );

问题是当我点击登录页面上的 Facebook 图标时,它会显示我的主页。 (index.php)

这里也是它指向的链接

http://localhost/dev/index.php/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835

当我从 url 中删除 index.php 时

http://localhost/dev/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835

我收到这个错误

您无法直接访问此页面。

知道我做错了什么吗?谢谢

【问题讨论】:

    标签: yii yii-extensions yii-modules


    【解决方案1】:

    这听起来像是您的配置中的路由问题:

    您可能想为 hybridauth.php 添加一个路由并确保它只能通过 GET 访问

    例如:

    'components'=>array(
        ......
        'urlManager'=>array(
            'showScriptName' => false,
            'urlFormat'=>'path',
            'rules'=>array(
                'hybridauth'=>array('user/hybridauth/index', 'verb'=>'GET', 'urlSuffix'=>'.php'),
                 ....
            ),
        ),
    ),
    

    【讨论】:

      【解决方案2】:

      如果有人遇到同样的问题,我是这样解决的:

      通过更改 base_url 以指向实际的 php 文件:

      "base_url" => Yii::app()->getBaseUrl(true).'/hybridauth.php', 
      

      【讨论】:

        【解决方案3】:

        如果你使用 YUM 用户管理尝试导入

         Yii::import('application.modules.profile.models.*');
        

        在 YumUserAuthController 上,因为找不到配置文件。

        【讨论】:

          猜你喜欢
          • 2015-07-18
          • 1970-01-01
          • 1970-01-01
          • 2011-11-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-11-30
          相关资源
          最近更新 更多