【发布时间】:2013-12-21 07:53:56
【问题描述】:
说明:
尝试将此 OAuth2 插件用于 CakePHP:
https://github.com/thomseddon/cakephp-oauth-server
已按照说明进行操作,现在转到此 URL:
http://mysite/oauth/login?response_type=code&client_id=NGYcZDRjODcxYzFkY2Rk&
redirect_url=http%3A%2F%2Fwww.return_url.com
(我们在数据库中创建了一个客户端,其信息与他在示例中使用的信息相同)
它会为电子邮件和密码打开一个登录框,但每次都无法通过身份验证。我相信它失败了,因为当它到达Cake's FormAuthenticate->authenticate() method 时,设置已恢复为'username'=>'username' 和'passwordHasher'=>'Simple'。
如果我们将这些行添加到FormAuthenticate($fields = ... 上方):
$this->settings['fields']['username'] = 'email';
$this->settings['passwordHasher'] = 'Blowfish';
然后登录成功。
我们尝试过的事情:
把它放在我们的 AppController 中,OAuthAppController,OAuthController(都在 beforeFilter 中):
$this->OAuth->authenticate = array(
'userModel' => 'Members',
'fields' => array(
'username' => 'email'
)
);
我们已经尝试在所有这些地方以及在我的 AppModel 中的初始 $components 数组中将其更改为新格式,例如 2.3:
$this->OAuth->authenticate = array(
'Form' => array(
'passwordHasher' => 'Blowfish',
'fields' => array('username'=>'email', 'password'=>'password'),
)
);
结束:
此时,我正在寻找任何方法(除了修改实际的 CakePHP 核心)以使其能够使用 email 而不是 username 登录(希望这能解决同样的问题将其从 Blowfish 恢复为 Simple 也存在问题。
我们已经尝试大量修改 OAuth 插件(无济于事)并且不反对再次尝试,但我们不知道要更改什么。
【问题讨论】:
-
看看这个问题:stackoverflow.com/questions/15090917/… 用户使用
$new_user['User']['username'] = $user['email'];-- 可能会给你一些见解?
标签: php cakephp authentication oauth-2.0 cakephp-2.3