如何验证 google openid 响应
我正在尝试向我的用户添加授权抛出 google openid 。我收到 ID (https://www. google.com/accounts/o8/id?id=AIt...Ew-Bo)但我如何检查它是否合法。我的意思是用户可以使用另一个用户的电子邮件创建恶意请求,我如何检查返回的电子邮件和声称的 ID 是否合法?
I'm trying to add authorization throw google openid to my users. I'm receiving id (https://www.google.com/accounts/o8/id?id=AIt...Ew-Bo) but how can i check that it's legit. I mean user can create malicious request with email of another user, how can i check that returning email and claimed id is legit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您确实应该使用为此目的创建的众多库之一,而不是尝试自己实现发现和签名验证。以下是各种编程语言的一堆:
http://openid.net/developers/libraries/
Rather than trying to implement discovery and signature verification by yourself, you really ought to use one of the many libraries that have already been created for this purpose. Here are a bunch for various programming languages:
http://openid.net/developers/libraries/
Google 的 OpenID(Google Apps for Domains OpenID 除外)只是标准 OpenID。您应该采取任何其他 OpenID 所需的所有预防措施,以确保断言合法。你是对的......任何人都可以制作一个 OpenID 肯定断言来欺骗你的 RP,除非你的 RP 验证签名、对标识符执行发现并将该标识符的授权 OP 端点与签署响应的端点相匹配。
至于您是否可以信任该电子邮件地址,那取决于您。您可以选择信任 Google OP 端点,然后您就知道了。
Google's OpenID (Google Apps for Domains OpenID excepted) is just standard OpenID. You should take all the precautions that any other OpenID requires to make sure the assertion is legit. You're right... anyone can craft an OpenID positive assertion to fool your RP unless your RP verifies the signature, performs discovery on the identifier and matches the authorized OP Endpoint for that identifier with the one that signed the response.
As for whether you can trust the email address, that's up to you. You can choose to trust the Google OP endpoint, and then you know.