【问题标题】:How does the validate() function stop fake authentication requests?validate() 函数如何阻止虚假身份验证请求?
【发布时间】:2013-02-15 03:59:56
【问题描述】:

我刚刚调试了一段我的登录代码没有正确验证请求的 php 代码。我不知何故跳过了使用 ->validate() 功能,我的一位网站测试人员通过从谷歌(下)获取响应并将他的电子邮件更改为管理员电子邮件,设法登录到管理员帐户。

http://mydomain/login/?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2013-02-15T03%3A56%3A27ZY153c0JFI0G5wA&openid.return_to=http%3A%2F%2Flocalhost%2Flogin%2F&openid.assoc_handle=AMlYA9UI33WW3XfuQGjITXSgB0a0x8nsqD91iuWK9mdvwyBm4EEbk08g&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.namePerson_first%2Cext1.value.namePerson_first%2Cext1.type.namePerson_last%2Cext1.value.namePerson_last%2Cext1.type.contact_email%2Cext1.value.contact_email&openid.sig=laAMatkmFjOPrKPsmaIEg%3D&openid.identity=https3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAawnUG6Mr7_ynO1mN-fThr9wbOo&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%OawnUG6Mr7_ymuB1mN-fTFhr9wbOo&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.namePerson_first=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffirst&openid.ext1.value.namePerson_first=T&openid.ext1.type.namePerson_last=http%3A%2F%2Faxschema.org%2FnamePerson%2Flast&openid.ext1.value.namePerson_last=M&openid.ext1.type.contact_email=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.contact_email=**myemail%email.com**

这让我们对 open id 如何使用 validate() 函数进行验证、请求来自何处、被发送回正确的源以及捕获未直接从 openid 服务器发送回的任何内容非常感兴趣? sig 或 identity 变量是否被用作某种公钥/私钥系统?

如果有人能帮助我理解那将是很酷的。

非常感谢

【问题讨论】:

    标签: php authentication openid lightopenid


    【解决方案1】:

    从提供者返回的肯定断言包含一个名为openid.signed 的字段,用于在消费者端验证openid.sig 中保存的签名。生成/验证签名的过程概述here。

    根据您显示的断言,这些是签名字段:

    op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle,ns.ext1,
    ext1.mode,ext1.type.namePerson_first,ext1.value.namePerson_first,
    ext1.type.namePerson_last,ext1.value.namePerson_last,ext1.type.contact_email,
    ext1.value.contact_email
    

    您可以看到ext1.value.contact_email 是签名字段之一,因此是签名的一部分,因此如果签名匹配,您可以确定该值没有被篡改。

    assoc_handle 指的是在 associate 方法期间在消费者和提供者之间建立的共享密钥。此共享密钥用于生成签名字段值的键控散列,形成要比较的签名。

    如果找不到共享密钥,则必须使用check_authentication 方法,概述here 并使用here。

    【讨论】:

    • 感谢您的回答。这似乎更清楚了,但我可能会再次阅读文档以完全掌握它!
    猜你喜欢
    • 2016-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多