improve: add support for database connection URIs #1168
Closed
+71
−134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related: #377
Related: #394
I set out to "simply" add support for connecting to PostgreSQL over Unix domain sockets using peer authentication, as that's what I like to use. But it avalanched into this, as I figured the easiest way to make that happen would be to support connection URIs with which underlying libraries would hopefully do the right thing.
Along the way it turned out that the potential problem of Slonik gratuitously specifying a
rejectUnauthorized
parameter is no longer present in current versions, it now seems to only specify it when requested to (which can be done through query string parameters in the connection URI). For what it's worthcentral-backend
uses Slonikv23.6.4
which is affected, the current46.0.1
has bettered its behaviour but looks quite different, while the earliest released version that has the correct behaviour isv25.1.0
.As I currently understand it, the corollary is this: With this new code, until we upgrade Slonik to
v25.1.0
(or later), people connecting to their databases over SSL will not be validating the server certificate fully. I tried a quick bump to v25.1.3 but that makes the unit tests fail; thus there'll be some work involved with that bump I suppose. For another day!