在 Perl 中实现 OpenID 提供程序

发布于 2024-09-05 19:03:48 字数 231 浏览 9 评论 0原文

这可能是盲目的,但我正在尝试使用 Net::OpenID::服务器模块。整个过程的文档混乱且稀疏。

如果有人在 Perl 中成功实现了提供程序,您可以粘贴一些代码片段吗?

This might be a shot in the dark, but I am trying to implement an OpenID Provider in Perl using the Net::OpenID::Server module. The documentation for the entire process is confusing and sparse.

If anyone has successfully implemented a provider in Perl, could you please paste some code snippets?

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

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

发布评论

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

评论(2

江湖正好 2024-09-12 19:03:48

所以我最终将 OpenID 安装到位,并且运行得很好。我想我会详细介绍我遇到的一些问题。

  • OpenID 登录过程有超过三个状态/步骤。这很令人困惑,因为文档和示例代码会让您相信有三个。在某些情况下,最多有七个。观察服务器日志并查看服务器和用户(请求身份验证的用户)访问提供商(您可能正在设置的内容)的次数。当您只查看一半的交互时,很难调试某些内容
  • 许多提供商正在使用未最终确定的 OpenID 2.0 规范。(稍微好一点。)2.0 规范的性能与 1.0 规范不同;服务器(他们)与提供者(您)建立信任。 Net::OpenID::Server 可以优雅地处理这个问题,但不会告诉您它正在使用什么规范。 2.0 规范在握手过程中添加了一个步骤。
  • 设置您自己的 OpenID 服务器以便于测试。我使用了一个简单的 Rails 服务器以及一个名为 ruby​​-openid 的 gem。设置模仿真实野外服务器的行为大约需要 10 分钟。
  • 这应该是不言而喻的,但请确保您的登录过程是无状态的。我们有一个全局变量来处理用户的验证方式。由于该变量的使用做出了与 OpenID 登录过程不兼容的某些假设,因此用户将被允许登录到自己以外的帐户。这显然是不好的。一些闭包,我们就有了一些无状态且更安全的代码。

总而言之,一旦使用 OpenID,它就会非常酷。

So I finally jiggered the OpenID installation into place and it's working pretty well. I figure I will detail some of the gotchas I ran into.

  • There are more than three states/steps to the OpenID sign-in process. This is confusing, because the documentation and sample code would lead you to believe that there are three. There are, in some cases, up to seven. Watch your server logs and see how many times a SERVER and USER (the ones requesting the authentication) hit the PROVIDER (what you are presumably setting up.) It's difficult to debug something when you're only looking at half of the interactions
  • Many providers are using the unfinalized OpenID 2.0 spec. (It's a little better.) The 2.0 spec performs differently from the 1.0 spec; the SERVER (them) establishes trust with the PROVIDER (you). Net::OpenID::Server handles this gracefully, but doesn't tell you what spec it's using. The 2.0 spec adds a step to the handshaking process.
  • Set up your own OpenID SERVER for easy testing. I used a simple Rails server with a gem called ruby-openid. It took about 10 minutes to set up to mimic behavior of a real in-the-wild server.
  • It should go without saying, but make sure your login process is stateless. We had a global variable that handled how the user was verified. Because use of that variable made certain assumptions that were incompatible with the OpenID sign-in process, users would have been allowed to log in to accounts other than their own. This is obviously bad. A few closures and we have some stateless and more secure code.

All in all, OpenID is pretty cool once you get it working.

烟雨凡馨 2024-09-12 19:03:48

仅供参考,Net-OpenID Perl 模块的开发正在启动,因此您可以期待大量的错误修复和更好的文档很快就会实现。有关详细信息,请查看 CPAN 和 openid-perl 群组。

Fyi, development on the Net-OpenID Perl modules is starting up so you can expect a big pile of bugfixes and better docs to hit real soon now. Check CPAN and the openid-perl group for details.

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