4

更新

尽管我不太确定为什么,但我设法让它工作了;) 似乎 python-openid 使用 POST 请求来发出 openid mode=associate 并且出于某种原因谷歌不喜欢那样。当我修补 python-openid 以使用 GET 请求时,一切正常。当我有更多信息时,我将继续我的调查并更新这篇文章。以下是我更改的差异。

--- python-openid-2.2.1.orig/openid/consumer/consumer.py
+++ python-openid-2.2.1/openid/consumer/consumer.py
@@ -229,6 +229,20 @@
     # 在异步代码共享的单独函数中处理响应。
     返回 _httpResponseToMessage(resp, server_url)

+def makeKVGet(request_message, server_url):
+ """向 OpenID 提供者直接请求并返回
+ 结果作为消息对象。
+
+ @raises openid.fetchers.HTTPFetchingError:如果出现错误
+ 在制作 HTTP 帖子时遇到。
+
+ @rtype: L{openid.message.Message}
+ """
+ # XXX: 测试
+ resp = fetchers.fetch(request_message.toURL(server_url))
+
+ # 在可以由异步代码共享的单独函数中处理响应。
+ 返回 _httpResponseToMessage(resp, server_url)

 def _httpResponseToMessage(response, server_url):
     """使 POST 响应适应消息。
@@ -682,6 +696,7 @@
         返回真

     _makeKVPost = 静态方法(makeKVPost)
+ _makeKVGet = 静态方法(makeKVGet)

     def _checkSetupNeeded(自我,消息):
         """检查一个 id_res 消息,看它是否是一个
@@ -1258,7 +1273,7 @@
             端点、关联类型、会话类型)

         尝试:
- 响应 = self._makeKVPost(args, endpoint.server_url)
+ 响应 = self._makeKVGet(args, endpoint.server_url)
         除了 fetchers.HTTPFetchingError,为什么:
             oidutil.log('openid.associate 请求失败: %s' % (why[0],))
             返回无

老问题,保留上下文

我一直在拼命想让trac-authopenid插件工作,但没有运气。

我们在工作中使用 Google Apps Premier,所以我试图让 openid auth 使用它。我想我已经设置了所有必需的东西(XRDS 等),就谷歌而言,我已经让它与 apache2 + mod-auth-openid以及在其他网站上使用它(SO for例子)。

但我似乎无法让它与 trac-authopenid 一起使用。我被重定向(通过表单帖子,而不是像往常一样的重定向)到我登录的谷歌,但是当我返回插件时,只是表明验证失败。

如果我打开调试日志,我会得到这个(我用 example.com 替换了我们的域名)

2010-01-27 12:21:15,811 Trac[authopenid] DEBUG: beginning OpenID authentication.
2010-01-27 12:21:16,866 Trac[authopenid] DEBUG: kvToSeq warning: Line 1 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:16,866 Trac[authopenid] DEBUG: kvToSeq warning: Line 2 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:16,866 Trac[authopenid] DEBUG: kvToSeq warning: Line 3 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
    ... snipped, repeats until line 9...
2010-01-27 12:21:16,867 Trac[authopenid] DEBUG: openid.associate request failed: bad status code from server https://www.google.com/a/example.com/o8/ud?be=
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root href: /trac
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root abs_href: https://developer.example.com/trac
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root href: /trac
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root abs_href: https://developer.example.com/trac
2010-01-27 12:21:16,869 Trac[authopenid] DEBUG: Generated checkid_setup request to https://www.google.com/a/example.com/o8/ud?be=o8 using stateless mode.
2010-01-27 12:21:18,068 Trac[main] DEBUG: Dispatching <Request "GET u'/openidprocess'">
2010-01-27 12:21:18,075 Trac[session] DEBUG: Retrieving session for ID '25a842642693232301aad341'
2010-01-27 12:21:18,078 Trac[authopenid] DEBUG: Error attempting to use stored discovery information: <openid.consumer.consumer.TypeURIMismatch: Required ty
2010-01-27 12:21:18,078 Trac[authopenid] DEBUG: Attempting discovery to verify endpoint
2010-01-27 12:21:18,078 Trac[authopenid] DEBUG: Performing discovery on http://example.com/openid?id=113663311178245814720
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: Received id_res response from https://www.google.com/a/example.com/o8/ud?be=o8 using association AOQobUefon
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: Using OpenID check_authentication
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: op_endpoint
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: claimed_id
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: identity
2010-01-27 12:21:18,122 Trac[authopenid] DEBUG: return_to
2010-01-27 12:21:18,122 Trac[authopenid] DEBUG: response_nonce
2010-01-27 12:21:18,122 Trac[authopenid] DEBUG: assoc_handle
2010-01-27 12:21:18,576 Trac[authopenid] DEBUG: kvToSeq warning: Line 1 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:18,577 Trac[authopenid] DEBUG: kvToSeq warning: Line 2 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:18,577 Trac[authopenid] DEBUG: kvToSeq warning: Line 3 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
    ... snipped, repeats until line 9...
2010-01-27 12:21:18,578 Trac[authopenid] DEBUG: check_authentication failed: bad status code from server https://www.google.com/a/example.com/o8/ud?be=o8: 501

我尝试直接针对python-openid库编写一些代码以缩小范围,但我一无所知。我已经能够使用此代码段重现错误:

from openid.store.memstore import MemoryStore
from openid.consumer import consumer

session = { 'id' : 'foobar' }
store = MemoryStore()
consumer = consumer.Consumer(session, store)
consumer.begin('https://www.google.com/accounts/o8/site-xrds?hd=example.com')

始终输出

kvToSeq warning: Line 1 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Implemented</H1>\n<H2>Error 501</H2>\n</BODY>\n</HTML>\n'
kvToSeq warning: Line 2 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Implemented</H1>\n<H2>Error 501</H2>\n</BODY>\n</HTML>\n'
kvToSeq warning: Line 3 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Implemented</H1>\n<H2>Error 501</H2>\n</BODY>\n</HTML>\n'
... snip ...
openid.associate request failed: bad status code from server https://www.google.com/a/example.com/o8/ud?be=o8: 501

一些版本号:

Python 2.6.2
trac-authopenid 0.1.6
python-openid 2.2.1

我完全不知所措,我真的可以使用一些帮助。

4

2 回答 2

2

好的。我没有应用程序帐户,因此无法测试登录,但我可以使用 python-openid 2.2.4 成功与应用程序域关联。这是一个用于发出关联请求的小调试工具:http: //gist.github.com/288560

你的补丁不应该有固定的东西;关联请求始终是 POST。并且 Ruby 库也总是 POST,所以除非 rpxnow 进行了一些不寻常的修改,否则当 python-openid 在这里失败时,rpxnow 不应该工作。

我正要问你关于openid.store你安装的问题,但如果你的 MemoryStore 最小示例重现了它,那不是它。

我想我剩下的唯一一件事就是建议您询问 Google Apps 客户支持。

于 2010-01-28T08:47:47.637 回答
0

您提到您正在使用带有 python-openid 的Python 2.6.2 。自述文件的要求部分目前仅列出 Python 2.3、2.4 或 2.5。很高兴听到你成功了。

于 2010-11-14T01:09:11.703 回答