Commit 3815d03
Remove assumption that the auth response is AuthenticateOk
pq currently assumes the message sent from the server after sending
PasswordMessage to be AuthenticationOk. However, this assumption doesn't
always stand as the server may send some other messages other than
AuthenticationOk such as another authentication request.
That occurs when lib/pq is trying to connect to a PgPool-II server,
where the following procedure is required as PgPool-II wants to have the
password in both Cleartext and MD5 formats:
[Client -> Server] StartupMessage
[Server -> Client] AuthenticationCleartextPassword
[Client -> Server] PasswordMessage
[Server -> Client] AuthenticationMD5Password
[Client -> Server] PasswordMessage
[Server -> Client] AuthenticationOk
[Server -> Client] ReadyForQuery
Current implementation of auth function of pq will fail if the message
after sending credentials is not AuthenticationOk, but we can just
return before checking it and let another loop of auth check it instead.
libpq does support handling multiple authentication requests, thus it
can connect to PgPool-II just fine with the procedure above. So making
pq check the message sent from the server after PasswordMessage will
solve the described issue and align its behavior with the official
client.1 parent 589ad43 commit 3815d03
2 files changed
Lines changed: 9 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| |||
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1227 | 1227 | | |
1228 | 1228 | | |
1229 | 1229 | | |
1230 | | - | |
1231 | 1230 | | |
1232 | 1231 | | |
1233 | 1232 | | |
1234 | 1233 | | |
1235 | 1234 | | |
1236 | 1235 | | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1253 | 1239 | | |
1254 | 1240 | | |
1255 | 1241 | | |
1256 | 1242 | | |
1257 | 1243 | | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
1273 | | - | |
| 1244 | + | |
| 1245 | + | |
1274 | 1246 | | |
1275 | 1247 | | |
1276 | 1248 | | |
| |||
0 commit comments