Yii 的 OpenId 支持
我想在 Yii 中使用 OpenID 支持。
在研究了可能的插件后,我找到了这两个。一种用于 OpenidSelector,一种用于 LightOpenId
http://www.yiiframework.com/extension/simpleopenidselector/
http://www.yiiframework.com/extension/loid
是这些是在 Yii 中用于 OpenId 支持的正确扩展吗?还要别的吗? 如果这些扩展正确的话,我想获得一些关于如何处理这些扩展的指南。
这是我认为除了按照页面上的说明安装它们之外我还需要做的事情。
- 创建 OpenIdUserIdentity 扩展 CUserIdentity 并将authenticate() 代码放在那里
- 创建一个登录页面并将 simpleopenidselector 代码放入视图中。
- 在 siteController 中创建一个 actionOpenIdLogin 方法
,然后我有点迷失了,因为我不理解 Loid 中的用法示例,并且我不知道如何执行上面的(1)和(3)。
请让我知道我是否走在正确的道路上,并可能提供一些指导。谢谢。
I want to play with OpenID support in Yii.
After researching for possible plugins, I found these two. One for OpenidSelector and one for LightOpenId
http://www.yiiframework.com/extension/simpleopenidselector/
http://www.yiiframework.com/extension/loid
Are these the right extensions to use in Yii for OpenId support? Anything else?
And I would like to get some guide line on what to do with these extensions if they are correct.
This is what I think I need to do beside installing them as per instructions on the page.
- Create OpenIdUserIdentity extends CUserIdentity and put the authenticate() code there
- Create a login page and put the simpleopenidselector code in a view.
- Create a actionOpenIdLogin methon in siteController
then I am kind of lost as I don't understand the Usage sample in Loid and I am not sure how to do (1) and (3) above.
Please let me know if I am on the right track and possibly provide some guidance. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
玩了一段时间后,我将回答我自己的问题。这就是我的工作方式,所以你可以根据你的需要更改它。
注意:我使用 userController 而不是 siteController,请遵循相应扩展页面中的所有说明。
如果您使用了上述两个插件,那么接下来您需要执行以下操作才能使其正常工作:(这是一步一步的指南)
但最重要的步骤是 2c 和 3,它们是两个插件的粘合剂
1)有一个使用 OpenidSelector 的登录页面。将其放置在views/user/login.php
2) 设置操作来处理来自openidSelector 的选择。我把它放在 userController 中。
a) 在主配置文件中。
b) 在 userController 文件中,添加登录和身份验证操作
操作 #1 actionLogin 的代码 - 这是为了触发登录视图页面。
c) 操作 #2 actionAuthenticate 的代码 - 从 LOID 指令页面修改的代码,用于在登录页面中选择 OpenIDProvider 时进行处理。
3) 将 openidProviders/views/main-en.php 中的操作 URL 更改为 Authenticate
更改
为
应该就是这样了。尚未测试失败案例,仅使用谷歌登录进行测试。
After playing with it for awhile, I am going to answer my own question. This is how I make it to work, so you can change it according to your needs.
Note: I use a userController instead of the siteController and please follow all the instructions in the respective extension page.
If you used the two plugins as indicated above, then what you need to do next to make it work are the followings: (this is a step by step guide)
But the most important steps are 2c and 3, they are the glue to both plugins
1) Have a login page that uses the OpenidSelector. Place it at views/user/login.php
2) Setup actions to handle the selection from the openidSelector. I put this in the userController.
a) In main config file.
b) In userController file, add login and authenticate actions
Code for action #1 actionLogin - this is to trigger the login view page.
c) Code for action #2 actionAuthenticate - code modified from the LOID instruction page, this is to handle when an OpenIDProvider is selected in the login page.
3) Change the action URL to Authenticate in the openidProviders/views/main-en.php
Change
to
That should be it. Haven't tested failure case, only tested with google login.
有 YiiAuth 现在,它使用 HybridAuth 库。
There is YiiAuth now, which makes use of the HybridAuth library.