2012-01-13 36 views
0

我可能失去了一些东西真的傻了,错过了Google Federated Login文档中,但如何在谷歌OpenID登录实际上确保对请求的网站?请求网站如何知道细节来自Google,而不仅仅是有人在URL中输入查询字符串参数?保护的谷歌的OpenID细节潜在欺骗到请求站点

为了说明这一点,我在PHP中实现了一个基本的OpenID登录序列,并且所有似乎返回的结果都是URL中的一串查询字符串参数,我可以使用它来获取OpenID详细信息,这非常有效。问题是,如果我只是手动输入到地址栏而没有实际登录Google,我的请求站点如何知道它们的区别?

首先,形式请求细节:

<form method='post' action='https://www.google.com/accounts/o8/ud'> 

    <input type='hidden' name='openid.return_to' value='http://www.example/com/logged-in' /> 

    <input type='hidden' name='openid.mode' value='checkid_setup' /> 
    <input type='hidden' name='openid.ns' value='http://specs.openid.net/auth/2.0' /> 
    <input type='hidden' name='openid.claimed_id' value='http://specs.openid.net/auth/2.0/identifier_select' /> 
    <input type='hidden' name='openid.identity' value='http://specs.openid.net/auth/2.0/identifier_select' /> 

    <input type='hidden' name='openid.ns.ax' value='http://openid.net/srv/ax/1.0' /> 
    <input type='hidden' name='openid.ax.mode' value='fetch_request' /> 
    <input type='hidden' name='openid.ax.required' value='email,firstname,lastname' /> 
    <input type='hidden' name='openid.ax.type.email' value='http://axschema.org/contact/email' /> 
    <input type='hidden' name='openid.ax.type.firstname' value='http://axschema.org/namePerson/first' /> 
    <input type='hidden' name='openid.ax.type.lastname' value='http://axschema.org/namePerson/last' /> 

    <input type='submit' value='Login With Google Account' /> 

</form> 

...伟大的工程,有一大堆的URL参数,如下图所示送我回请求站点http://www.example.com/logged-in(从PHP print_r调用):

Array 
(
    [openid_ns] => http://specs.openid.net/auth/2.0 
    [openid_mode] => id_res 
    [openid_return_to] => http://www.example.com/logged-in 
    [openid_ext1_type_firstname] => http://axschema.org/namePerson/first 
    [openid_ext1_value_firstname] => {user's first name} 
    [openid_ext1_type_email] => http://axschema.org/contact/email 
    [openid_ext1_value_email] => {user's e-mail address} 
    [openid_ext1_type_lastname] => http://axschema.org/namePerson/last 
    [openid_ext1_value_lastname] => {user's last name} 
) 

...这是真棒,但我怎么知道,这其实就是一个合法的要求,而不是有人在上面的参数输入到地址栏?

感谢您的帮助,道歉,如果这已被要求已经(找不到任何副本!),如果我失去了一些东西明显!

回答

1

没有进入太多细节(阅读OpenID的规范,如果你需要的血淋淋的细节)OpenID协议已制定保障措施这一点。您收到的断言是有签名和可验证的,ID的命名空间有限制,以防止提供者欺骗对方的ID。如果您使用的是已建立的库(例如,php-openid很好),您不必太担心这件事,因为它通常会在封面下面进行处理。如果你试图推出自己的实现....好吧,只是不要...

这就是说,有一些事情,不是协议覆盖。例如,尽管在响应中签名属性,但除非您信任特定提供商,否则不能认为它们是准确的。有些应用程序会检查提供断言的提供商的URL /主机名(验证响应后),并将已知的身份提供商列入白名单,以便进行适当的电子邮件验证。如果你需要一个经过验证的电子邮件,这样做会使用户获得更好的UX。但是,如果断言来自未知的身份提供者,则不要假设该电子邮件地址实际上属于该用户,除非您自己验证拥有权。

+0

只是不?真的吗?你知道你让我想更多地调查这个,对吗? ; P我最近遇到了另一个利用OpenID的方面,特别是Google登录,称为'nonce'。基本上只使用一次的随机数,这些随机数的可以用来帮助保护认证,但它仍然看起来像一个狂热的黑客可以在上面和伪造仍然跳自己的方式。感谢您抽出宝贵时间来回应史蒂夫! – 2012-01-27 09:40:14