如何实现与Zend的OpenID身份直接基于OpenID身份验证 [英] How do I implement Direct Identity based OpenID authentication with Zend OpenID

查看:103
本文介绍了如何实现与Zend的OpenID身份直接基于OpenID身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Zend框架,并从 HTTP的OpenID的选择:// code.google.com / p / OpenID的选择/ - 但是我发现他们使用直接的基于身份登录系统,使一个刚刚重定向到URL我不能使用像谷歌和雅虎网站登录而不是进入一个属于自己的唯一的URL进行身份验证。

I'm using the Zend framework and the openid selector from http://code.google.com/p/openid-selector/ - however I find I can't login using sites like Google and Yahoo as they use direct identity based login system whereby one is just redirected to a url as opposed to entering a unique url of their own for authentication.

我已经签出许多选项和黑客,但他们都不工作。我怎样才能得到这个在这里工作的BTW - 它是如何在堆栈溢出实施?我真的可以使用所有帮助这里家伙..

I've checked out many options and hacks but none of them seem to work. How can i get this to work here btw - how is it implemented at stack overflow? I could really use all the help here guys..


修改

那么这里的问题是,从我注意到的是,在Zend OpenID的类不支持OpenID 2.0的事情是,一个典型的开放ID providor给你一个唯一的URL,如您-name.openid-providor。 COM或openid-providor.com/your-name和Zend的OpenID类只是解析通过URL,然后将您重定向到providor网站,在认证时会被重定向回来。

Well the issue here is that from what I have noticed is that the Zend OpenID class doesn't support OpenID 2.0 the thing is that a typical open ID providor gives you a unique url such as your-name.openid-providor.com or openid-providor.com/your-name and the Zend OpenId class just parses through that url and then redirects you to the providor website where upon authentication you are redirected back.

在雅虎和谷歌的情况下 - 你没有输入一个唯一的URL,而不是你会被重定向到providors登录网站,并在登录和认证用户会被重定向回 - 所以基本上什么happeining是,当解析zend_openID对象说谁的providor是它无法从一般的URL本身告诉。当您单击德谷歌链接,喜欢的话您重定向到https://www.google.com/accounts/o8/id

In the case of Yahoo and google - you don't enter a unique url instead you are redirected to the providors login site and upon login and authentication you are redirected back - so basically whats happeining is that the zend_openID object when it parses to tell who the providor is it fails to tell from the general url itself. Like when you click on teh Google link it redirects you to https://www.google.com/accounts/o8/id

其更在这里了Zend OpenID的对象的问题并没有在Zend的相关论坛的帮助 - 所以我在想,如果有人已经砍死或进行了全面改造,我可以做的类来实现。很抱歉,如果我失去了一些东西,但我有点新的这个和开放ID的编程和刚开始让我的脚湿。

Its more an issue with the zend openid object here and there isn't any help on zend related forums - so I was wondering if someone had already hacked or had an alteration I could make to the class to accomplish this. Sorry if I'm missing something but I'm kinda new to this and programming with open ID and have just started to get my feet wet.


感谢跟进 - 我没有检查到RPX而回,他们确实有一个PHP类,但我不是能检查出来再加上我真的只是想现在得到code选择用作计算器与雅虎和谷歌的认证工作。必须有某种方式来调整其在Zend的OpenID类使用解析,因为它运行一系列常规的前pression检查做出的发现。

Thanks for the follow up - I did check into RPX a while back and they do have a php class but I wasnt able to check it out plus I really just want to for now get the code selector used as on stackoverflow to work with Yahoo and Google authentication. There has to be some kind of way to tweak the parsing which the Zend OpenID class uses as it runs a series of regular expression checks to make a discovery.

推荐答案

有点晚了比赛,但我能得到一些黑客,我发现周围的interwebs这方面的工作。

Little late to the game but I was able to get this working with some hacks I found around the interwebs.

第一。雅虎。得到雅虎的工作一切我所要做的就是改变JavaScript才能使用 me.yahoo.com ,而不是仅仅的 yahoo.com ,并用它在Zend的版本完美地工作框架我使用。不幸的是谷歌还是没有,所以一些黑客是为了。

First. Yahoo. To get Yahoo working all I had to do was change the JavaScript to use me.yahoo.com instead of just yahoo.com and it worked perfectly with the version of the Zend Framework I'm using. Unfortunately Google still wasn't, so some hacking was in order.

在所有这些变化去的Zend /的OpenID / Consumer.php

首先,在 _discovery 方法添加的启动大约740线系列preg_match检查以下内容。

First, in the _discovery method add the following on the series of preg_match checks that starts at around line 740.

} else if (preg_match('/<URI>([^<]+)<\/URI>/i', $response, $r)) {
    $version = 2.0;
    $server = $r[1];

我添加了这一权利之前,返回false;这是在其他{}块语句

第二, _checkId 方法,你需要添加新的3块(我还没有足够的周围挖知道是什么原因导致每个这三种情况是调用,所以我涵盖了所有要在安全方面。

Second, in the _checkId method you'll need to add 3 new blocks (I haven't dug around enough to know what causes each of these three cases to be called, so I covered all to be on the safe side.

在$版本&LT; = 2.0块,你会发现一个的if / else的if / else块。在第一个if语句($这个 - &GT; _session == NULL!)将此添加到末尾:

Inside the $version <= 2.0 block, you'll find an if/else if/else block. In the first if statement ($this->_session !== null) add this to the end:

if ($server == 'https://www.google.com/accounts/o8/ud') {
    $this->_session->identity = 'http://specs.openid.net/auth/2.0/identifier_select';
    $this->_session->claimed_id = 'http://specs.openid.net/auth/2.0/identifier_select';
}

在别人如果(定义(SID)街区添加到末尾:

In the else if (defined('SID') block add this to the end:

if ($server == 'https://www.google.com/accounts/o8/ud') {
    $_SESSION['zend_openid']['identity'] = 'http://specs.openid.net/auth/2.0/identifier_select';
    $_SESSION['zend_openid']['claimed_id'] = 'http://specs.openid.net/auth/2.0/identifier_select';
}

然后else块后(所以外面的if / else的if / else块都在一起,但还是里面的$版本&LT; = 2.0块)补充一点:

And then after the else block (so outside the if/else if/else block all together, but still inside the $version <= 2.0 block) add this:

if ($server == 'https://www.google.com/accounts/o8/ud') {
    $params['openid.identity'] = 'http://specs.openid.net/auth/2.0/identifier_select';
    $params['openid.claimed_id'] = 'http://specs.openid.net/auth/2.0/identifier_select';
}

链接到错误Zend框架问题跟踪

这篇关于如何实现与Zend的OpenID身份直接基于OpenID身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆