为什么 Google 的 OpenID 实现的 ID 会发生变化?

发布于 2024-08-29 17:02:53 字数 417 浏览 3 评论 0原文

我正在尝试为 Web 应用程序实现 OpenId 登录。每当新用户通过 OpenId 登录时,我都会在系统上创建一个新用户,并在数据中存储他们的 openid URL,以便下次他们使用该用户登录时。

我正在使用 Gmail OpenID 对此进行测试,问题是每次我执行此操作时,Google 都会发送不同的 openid URL,即 https://www.google.com/accounts/o8/id?id=SomethingThatChangesFromTimeToTime

当然,我无法判断这是否是新用户。我有点困惑:openid 标识符不应该始终保持不变吗?

I'm trying to implement OpenId login for a web application. Whenever new user who logs in via OpenId I create a new user on the sustem, and among the data I store their openid URL, so that next time they login with that user.

I'm testing this with my Gmail OpenID, and the problem is that everytime I do this, Google sends a different openid URL, that is, https://www.google.com/accounts/o8/id?id=SomethingThatChangesFromTimeToTime

Of course I'm then not able to tell wheter this is or not a new user. I'm a bit puzzled: shouldn't the openid identifier always remain the same?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宛菡 2024-09-05 17:02:53

Google 的 OpenID 标识符或多或少是多个数据的哈希表示,包括请求来自的主机(更准确地说是发送给提供商的 openid.realm 参数)。因此,如果您的主机不时发生变化(例如端口和IP地址发生变化),那么ID也会不时发生变化。 StackOverflow 也使用了解决此问题的方法。查看这些帖子:

以下是来自 google 的常见问题解答摘录:

问:OpenID 规范规定 openid.realm 是可选的,如果未提供,Google 应使用 openid.return_to URL。这行得通吗?

答:从协议成功完成的意义上来说,它会起作用。但如果您的 return_to 网址类似于 www.example.com/authenticate?style=openid-federated_login,则您是在要求我们提示用户批准并信任特定地址在您的网站上,这对用户不友好。此外,如果您省略 openid.realm 参数,您将永远无法更改您的 return_to 网址:它还会隐式更改您的 Google 领域和网址标识符帐户用户。

Google's OpenID identifier is more or less a hashed representation of multiple data including the host the request came from (more exactly the openid.realm parameter sent to the provider). So if your host changes from time to time (like the port and ip address changes), then the ID will change from time to time too. StackOverflow uses a workaround for this issue too. Check these posts:

Here is an FAQ excerpt from google:

Q: The OpenID spec says that the openid.realm is optional, and that if not provided, Google should use the openid.return_to URL instead. Will that work?

A: It will work in the sense that the protocol will complete successfully. But if your return_to URL is something like www.example.com/authenticate?style=openid-federated_login, you are asking us to prompt users to approve and trust a specific address at your site, which is not user-friendly. Also, if you omit the openid.realm parameter, you will never be able to change your return_to URL: It will also implicitly change the realm and the URL identifiers of your Google Account users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文