feat(pg-connection-string): support the sslpassword parameter - #3789
u9822914324-web wants to merge 2 commits into
Conversation
|
Apologies — my previous comment lost its formatting and came through with the code spans stripped. Reposting it properly. Added one more commit: (That file does not satisfy |
Parses sslpassword from the connection string and assigns it to config.ssl.passphrase, which is the Node TLS option used to decrypt an encrypted ssl.key. Issue brianc#3716 asked for this under the name `sslpassphrase`; charmander noted there that the libpq-compatible spelling is `sslpassword`, so that is the name implemented here. Unlike sslcert, sslkey and sslrootcert, sslpassword is a literal value rather than a path, so it is not read from disk. It is added to the condition that initialises config.ssl so that it works on its own, matching how the other ssl parameters behave. toClientConfig passes the whole ssl object through toConnectionOptions, so passphrase reaches ClientConfig without further plumbing. Closes brianc#3716 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sslpassword now participates in the condition that initialises config.ssl, so like sslcert, sslkey, sslrootcert and sslmode it causes an ssl object supplied alongside a connection string to be replaced. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
73d17b0 to
387265d
Compare
|
Force-pushed to rebase onto No change to the code under review. |
Closes #3716.
What
Parses
sslpasswordfrom the connection string and assigns it toconfig.ssl.passphrase— the Node TLS option used to decrypt an encryptedssl.key.On the parameter name
The issue requested
sslpassphrase, but @charmander pointed out in the thread that the libpq-compatible spelling issslpassword. This implementssslpassword.Notes on the implementation
sslcert,sslkeyandsslrootcert,sslpasswordis a literal value rather than a path, so it is deliberately not read from disk and does not pull infs.config.ssl, so it works on its own rather than throwing on an undefinedconfig.ssl. That matches how the otherssl*parameters already behave.toClientConfigpasses the whole ssl object throughtoConnectionOptions, sopassphrasereachesClientConfigwithout extra plumbing — confirmed by reading that function rather than assuming.SSLConfiginindex.d.tsgainspassphrase?: string.ssl*entries.Testing
Three tests added to
packages/pg-connection-string/test/parse.ts: the parameter on its own, alongsidesslkey, and URL-decoding of special characters (the last confirms the existing query parsing decodes the value, so passwords containing/,?,&or=survive).Full
pg-connection-stringsuite, 0 failing.prettier --checkpasses onindex.js,index.d.tsandtest/parse.ts.The package README does not currently satisfy
prettier --checkonmain, so I left its existing formatting alone rather than reformatting unrelated lines.One thing worth flagging
A password in a connection string can end up in logs, shell history, and process listings. If you would like a caution in the README similar to the existing
sslmodeone, I am happy to add it — I did not want to expand the scope unasked.Prepared with AI assistance (Claude); behaviour verified by the tests above.
🤖 Generated with Claude Code