简体   繁体   English

您如何在本地针对OpenID进行开发

[英]How do you develop against OpenID locally

I'm developing a website (in Django) that uses OpenID to authenticate users. 我正在开发一个使用OpenID来验证用户身份的网站(在Django中)。 As I'm currently only running on my local machine I can't authenticate using one of the OpenID providers on the web. 由于我目前只在本地计算机上运行,​​因此无法使用Web上的某个OpenID提供程序进行身份验证。 So I figure I need to run a local OpenID server that simply lets me type in a username and then passes that back to my main app. 所以我想我需要运行一个本地OpenID服务器,只需让我输入用户名,然后将其传递回我的主应用程序。

Does such an OpenID dev server exist? 这样的OpenID开发服务器是否存在? Is this the best way to go about it? 这是最好的方式吗?

The libraries at OpenID Enabled ship with examples that are sufficient to run a local test provider. OpenID Enabled中的库提供了足以运行本地测试提供程序的示例。 Look in the examples/djopenid/ directory of the python-openid source distribution. 查看python-openid源代码分发的examples / djopenid /目录。 Running that will give you an instance of this test provider . 运行它将为您提供此测试提供程序的实例。

I have no problems testing with myopenid.com . 我用myopenid.com测试没问题。 I thought there would be a problem testing on my local machine but it just worked. 我以为在我的本地机器上测试会有问题,但它确实有效。 (I'm using ASP.NET with DotNetOpenId library). (我正在使用ASP.NET和DotNetOpenId库)。

The 'realm' and return url must contain the port number like ' http://localhost:93359 '. 'realm'和return url必须包含端口号,如' http:// localhost:93359 '。

I assume it works OK because the provider does a client side redirect. 我认为它工作正常,因为提供程序执行客户端重定向。

I'm also looking into this. 我也在调查这个。 I too am working on a Django project that might utilize Open Id. 我也正在开发一个可能利用Open Id的Django项目。 For references, check out: 如需参考,请查看:

Hopefully someone here has tackled this issue. 希望有人在这里解决了这个问题。

I'm using phpMyID to authenticate at StackOverflow right now. 我现在正在使用phpMyID在StackOverflow上进行身份验证。 Generates a standard HTTP auth realm and works perfectly. 生成标准的HTTP身份验证领域并且运行良好。 It should be exactly what you need. 它应该是你需要的。

You could probably use the django OpenID library to write a provider to test against. 您可以使用django OpenID库编写供测试的提供程序。 Have one that always authenticates and one that always fails. 有一个总是在验证,一个总是失败。

Why not run an OpenID provider from your local machine? 为什么不从本地计算机运行OpenID提供程序?

If you are a .Net developer there is an OpenID provider library for .Net at Google Code . 如果您是.Net开发人员,则可以在Google Code上使用.Net的OpenID提供程序库。 This uses the standard .Net profile provider mechanism and wraps it with an OpenID layer. 它使用标准的.Net配置文件提供程序机制,并使用OpenID层包装它。 We are using it to add OpenID to our custom authentication engine. 我们正在使用它将OpenID添加到我们的自定义身份验证引擎中。

If you are working in another language/platform there are a number of OpenID implementation avalaiable from the OpenID community site here . 如果您在另一种语言/平台的工作也有一些从OpenID的社区网站的OpenID实现avalaiable的位置

You shouldn't be having trouble developing against your own machine. 您不应该在自己的机器上进行开发时遇到问题。 What error are you getting? 你遇到了什么错误?

An OpenID provider will ask you to give your site (in this case http://localhost:8000 or similar) access to your identity. OpenID提供商会要求您提供您的网站(在本例中为http:// localhost:8000或类似网站)访问您的身份。 If you click ok then it will redirect you that url. 如果单击“确定”,则会重定向该URL。 I've never had problems with livejournal and I expect that myopenid.com will work too. 我从来没有遇到过livejournal的问题,我希望myopenid.com也能运作。

If you're having problems developing locally I suggest that the problem you're having is unrelated to the url being localhost, but something else. 如果您在本地开发时遇到问题,我建议您遇到的问题与本地主机的URL无关,而是与其他内容无关。 Without an error message or problem description it's impossible to say more. 没有错误消息或问题描述,就不可能多说。

Edit : It turns out that Yahoo do things differently to other OpenID providers that I've come across and disallow redirections to ip address, sites without a correct tld in their domain name and those that run on ports other than 80 or 443. See here for a post from a Yahoo developer on this subject. 编辑 :事实证明,雅虎做的事情与我遇到的其他OpenID提供商的做法不同,不允许重定向到IP地址,域名中没有正确tld的站点以及在80或443以外的端口上运行的站点。请参阅此处有关此主题的雅虎开发人员的帖子。 This post offers a work around, but I would suggest that for development myopenid.com would be far simpler than working around Yahoo, or running your own provider. 这篇文章提供了一个解决方案,但我建议,对于开发myopenid.com比在雅虎工作或运行自己的提供商要简单得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM