MagicStack / MagicStack/asyncpg

authentication issue with md5 on postgres 11

オープン
#626 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
8.1k
フォーク
468
PR マージ指標
30日以内にマージされた PR はありません

説明

* **asyncpg version**: 0.21.0 and lower
* **PostgreSQL version**: 11
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**:
* **Python version**: 3.6.0
* **Platform**: linux 3.10.0
* **Do you use pgbouncer?**: No
* **Did you install asyncpg with pip?**: Yes
* **If you built asyncpg locally, which version of Cython did you use?**:
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**:

> We have the same code. When running with useridAAA with password, it works on some servers, but not on other servers. The useridAAA's password is authenticated with md5 on the postgres. If we switch to useridBBB, which is authenticated as SHA256 on postgres. It works on all servers. It's the same password for useridAAA and useridBBB. What's dictating the hash on the password on the client side?

Below is the error message when couldn't be authenticated.
`DEBUG: Using selector: EpollSelector

DEBUG: Get address info edclpgsd320c.bcbsfl.com:5420, type=

DEBUG: Getting address info edclpgsd320c.bcbsfl.com:5420, type= took 2.792 ms: [(, , 6, '', ('))]

DEBUG: poll 59997.326 ms took 1.820 ms: 1 events

DEBUG: connect to ()

DEBUG: poll 59993.166 ms took 0.141 ms: 1 events

DEBUG: connected to : (<_SelectorSocketTransport fd=6 read=polling write=>, )

DEBUG: poll 59990.760 ms took 0.014 ms: 1 events

INFO: poll 59990.568 ms took 60000.243 ms: 1 events

DEBUG: <_SelectorSocketTransport fd=6 read=polling write=> received EOF

Traceback (most recent call last):

File "asyncdb3c.py", line 52, in

app = loop.run_until_complete(init_app())

File "/usr/lib64/python3.6/asyncio/base_events.py", line 484, in run_until_complete

return future.result()

File "asyncdb3c.py", line 34, in init_app

pool = await asyncpg.create_pool("postgres://useridAAA:------@------.-----.com:5490/xxx01s1?application_name=aaa",min_size=1, max_size=3,max_inactive_connection_lifetime=3)

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/pool.py", line 398, in _async__init__

await self._initialize()

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/pool.py", line 426, in _initialize

await first_ch.connect()

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/pool.py", line 125, in connect

self._con = await self._pool._get_new_connection()

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/pool.py", line 472, in _get_new_connection

**self._connect_kwargs)

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/connection.py", line 1727, in connect

max_cacheable_statement_size=max_cacheable_statement_size)

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/connect_utils.py", line 666, in _connect

connection_class=connection_class)

File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__

return self.gen.send(None)

File "/u/i3ye/ppx/lib64/python3.6/site-packages/asyncpg/connect_utils.py", line 642, in _connect_addr

await asyncio.wait_for(connected, timeout=timeout)

File "/usr/lib64/python3.6/asyncio/tasks.py", line 358, in wait_for

return fut.result()

asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation

`

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、traceback に示されている asyncpg.create_pool または asyncpg.connect のエントリポイントを使用して PostgreSQL 11 で失敗を再現し、md5 認証ユーザーと SHA256 認証ユーザーを比較します。asyncpg/connect_utils.py 周辺の接続経路を読み、想定されるクライアントの動作と再現可能なテストケースを明らかにします。md5 認証の違いが説明または修正され、検証されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
postgresql, python
領域
authentication, backend, databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。