From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4251: OAuth implementation
Date: Wed, 09 Sep 2026 15:45:35 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4251-rc3970363209@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4251@github.com>
References: <gh-pgjdbc-pgjdbc-4251@github.com>
(on pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java:1273)
This is the first blocking finding from the review body. After the server has said the token is invalid, the driver sends the dummy response and calls `setFinishedAuthenticationRequests()` without recording that a rejection arrived, so the next `AuthenticationOk` is accepted and `getConnection()` returns a live connection.
libpq keeps a state for exactly this. `oauth_exchange` sets `FE_OAUTH_SERVER_ERROR` after `handle_oauth_sasl_error`, and any further server message then fails the connection with `server sent additional OAuth data after error`. RFC 4422 section 3.6, which RFC 7628 section 3.2.3 cites, is the rule behind it.
A boolean on the authenticator covers it: set it here, and throw from `AUTH_REQ_OK` and `AUTH_REQ_SASL_FINAL` when it is set. Worth a test with a fake backend, since no real server produces this sequence.
Two smaller points on the same lines. The comment restates the method name below it; what a reader cannot see is why no further request arrives, which is that the dummy response closes the error sequence and the server answers with `ErrorResponse`. And the JSON reaches the log at `WARNING` but never reaches the exception, so a user reading the stack trace loses the `status` and `scope` fields that libpq parses and uses.