pg.ddx.io  GitHub: pgjdbc/pgjdbc (issues + PRs as email threads)  
help / color / mirror / Atom feed
From: davecramer (@davecramer) <noreply+davecramer@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4251: OAuth implementation
Date: Thu, 25 Jun 2026 11:20:04 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4251-c4798663272@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4251@github.com>
References: <gh-pgjdbc-pgjdbc-4251@github.com>

> Hi @davecramer, at the time when I started to work on this, as discussed in #4251, there was no your PR yet. Yesterday, before sending this PR, I found yours but it looked stale and incomplete. Do you plan to finish it and what is the plan in general? Just for the context this PR is not just prompt feed to AI, I worked on RFCs, other libraries implementations, libpq internals and Postgres mailing lists. OAuth topic turned out not so simple and it has some nuances, especially regarding discovery phase. Also before sending this PR I passed internal review within my company by principal engineers. So I think it's already in a pretty good state, what is confirmed by @vlsi review.
> 
> I would appreciate clarity what to do next. Thanks!

Hi @artemgavrilov — thanks for putting together a solid implementation. The RFC 7628 message format is correct, the RFC 6750 token validation regex is a nice touch, and having real integrationtests with Keycloak is the right approach. This is a strong foundation. 

  A few recommendations before this can merge:

  1. OAuthTokenProvider.getToken() needs a context argument

  The current no-argument signature means a provider has no way to know which server it's acquiring a token for, what scope was requested, or what issuer the server advertises. In practice this forces implementors to either hardcode that configuration or read it from out-of-band sources — which defeats the purpose of a plugin interface. More importantly, discovery (when it lands) will need to pass the server-advertised issuer URL and scope to the provider, which means the signature will have to change after this is already a public API. Better to define it correctly once:

  public interface OAuthTokenProvider {
      String getToken(OAuthTokenRequest request) throws PSQLException;
  }

  Where OAuthTokenRequest carries host, port, user, database, discoveryUrl, scope, and clientId. Fields can be null when not yet known — providers can ignore what they don't need. This is the only change I'd call a blocker since it's a public API that would be painful to change post-merge.

  2. CI platform: linux/amd64 pin

  The pin affects all Docker test scenarios, not just OAuth — SSL, XA, SCRAM, and replication tests all run under emulation on ARM64 hosts. Scope it to the Keycloak container specifically, or remove it and accept that the OAuth test only runs on amd64 CI runners.

  3. Consider a lightweight validator alternative

  Keycloak is a significant dependency for CI. The pgx project uses a minimal dummy_validator.c PostgreSQL extension that validates tokens without a full IdP. That would make the test environment faster and less prone to keycloak:latest drift. Keycloak has the advantage of testing a realistic flow, so this is a trade-off worth discussing rather than a hard recommendation.

  4. Token zeroing

  resolveOAuthToken returns a String, which can't be zeroed after use. The driver already handles passwords as char[] for this reason — must be fixed for security reasons.

  The requireAuth=oauth-bearer naming is worth aligning with the rest of the project where methods use shorter names (scram-sha-256, password, gss). Minor, but consistency helps.

  Overall this is closer to ready than #4087. The provider interface change is the one thing I'd call a blocker since it's a public API that would be painful to change post-merge.

I'll close mine in favour of this.


view thread (168+ messages)  latest in thread

Message-ID: <gh-pgjdbc-pgjdbc-4251-c4798663272@github.com>
Permalink:  ../gh-pgjdbc-pgjdbc-4251-c4798663272@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox