Yii 用户管理混合身份验证设置
我正在尝试在Yii用户管理插件上设置混合身份验证,文档在这里 按照这个步骤Yii 用户管理混合身份验证设置,yii,yii-extensions,yii-modules,Yii,Yii Extensions,Yii Modules,我正在尝试在Yii用户管理插件上设置混合身份验证,文档在这里 按照这个步骤 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/vend
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
我得到这个错误
您无法直接访问此页面。
知道我做错了什么吗?谢谢这听起来像是配置中的路由问题: 您可能希望为hybridauth.php添加一个路由,并确保它只能由GET访问 例如:
'components'=>array(
......
'urlManager'=>array(
'showScriptName' => false,
'urlFormat'=>'path',
'rules'=>array(
'hybridauth'=>array('user/hybridauth/index', 'verb'=>'GET', 'urlSuffix'=>'.php'),
....
),
),
),
如果有人有同样的问题,下面是我如何解决的: 通过更改base_url以指向实际的php文件:
"base_url" => Yii::app()->getBaseUrl(true).'/hybridauth.php',
如果使用YUM用户管理,请尝试导入
Yii::import('application.modules.profile.models.*');
在YumUserAuthController上,因为找不到配置文件