アップデート
理由はよくわかりませんが、なんとか動作させることができました;) python-openid は POST リクエストを使用して openid mode=associate を発行しているようですが、何らかの理由で Google はそれを好まないのです。代わりに GET-request を使用するように python-openid にパッチを適用すると、すべてが正常に機能しました。調査を続け、詳細がわかり次第、この投稿を更新します。以下は私の変更の差分です。
--- python-openid-2.2.1.orig/openid/consumer/consumer.py
+++ python-openid-2.2.1/openid/consumer/consumer.py
@@ -229,6 +229,20 @@
# 非同期コードで共有できる別の関数で応答を処理します。
return _httpResponseToMessage(resp, server_url)
+def makeKVGet(request_message, server_url):
+ """OpenID プロバイダーに直接リクエストを行い、
+ Message オブジェクトとしての結果。
+
+ @raises openid.fetchers.HTTPFetchingError: エラーが発生した場合
+ HTTP ポストの作成中に遭遇しました。
+
+ @rtype: L{openid.message.Message}
+ """
+ # XXX: テスト
+ resp = fetchers.fetch(request_message.toURL(server_url))
+
+ # 非同期コードで共有できる別の関数で応答を処理します。
+ return _httpResponseToMessage(resp, server_url)
def _httpResponseToMessage (応答、server_url):
"""POST 応答をメッセージに適応させます。
@@ -682,6 +696,7 @@
真を返す
_makeKVPost = staticmethod(makeKVPost)
+ _makeKVGet = staticmethod(makeKVGet)
def _checkSetupNeeded (自己、メッセージ):
"""id_res メッセージをチェックして、それが
@@ -1258,7 +1273,7 @@
エンドポイント、assoc_type、session_type)
試す:
- 応答 = self._makeKVPost(args, endpoint.server_url)
+ 応答 = self._makeKVGet(args, endpoint.server_url)
fetchers.HTTPFetchingError を除く、理由:
oidutil.log('openid.associate リクエストが失敗しました: %s' % (なぜ[0],))
返却なし
文脈のために保存された古い質問
私は必死にtrac-authopenidプラグインを動作させようとしましたが、うまくいきませんでした。
仕事でGoogle Apps Premierを使用しているので、openid認証をそれで機能させようとしています。Googleに関する限り、必要なもの(XRDSなど)をすべてセットアップしたと思います.apache2 + mod-auth-openidで正常に動作するようになり、他のサイトで使用することもできました(SO for例)。
しかし、trac-authopenid で動作させることができないようです。私は(通常のリダイレクトではなく、フォーム投稿を介して)Googleにリダイレクトされ、そこでログインできますが、プラグインを返すと、検証に失敗したことが示されます。
デバッグ ログをオンにすると、これが表示されます (ドメイン名を 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
私は完全に途方に暮れており、本当に助けが必要です。