-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support libpq's channel_binding and require_auth (and enforce them against every authentication request)
#3746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jawj
wants to merge
10
commits into
brianc:master
Choose a base branch
from
jawj:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b93c6ea
Add support for channel_binding and require_auth connection parameter…
jawj 9febd2a
Merge remote-tracking branch 'upstream/master'
jawj aea2cb9
Exclude Node 16 from SSL tests (libpq fails to get server cert in nat…
jawj 3124258
Remove PGTESTNOSSL again, and guard the specific unavoidably-failing …
jawj fd99925
Make enableChannelBinding emit a deprecation warning; allow booleans …
jawj a246b6d
Remove some busy-waits from tests; abridged some comments
jawj 9686fb6
Implement waitForSuccess in tests instead of waiting then testing for…
jawj 20a6005
Small assertiomn tweak
jawj 170a64b
Update CHANGELOG.md
jawj 89c1215
Linting fixes
jawj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| 'use strict' | ||
|
|
||
| // Support for libpq's channel_binding parameter, which says whether SCRAM authentication | ||
| // has to be bound to the server's certificate: | ||
| // https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-CHANNEL-BINDING | ||
|
|
||
| const nodeUtils = require('util') | ||
| const defaults = require('./defaults') | ||
|
|
||
| const channelBindingLevels = ['disable', 'prefer', 'require'] | ||
|
|
||
| const emitEnableChannelBindingDeprecationNotice = nodeUtils.deprecate( | ||
| () => {}, | ||
| 'enableChannelBinding is deprecated: instead, please set channel_binding to "disable", "prefer" or "require"' | ||
| ) | ||
|
|
||
| function channelBindingFromDeprecatedBoolean(value) { | ||
| if (value === undefined) return // undefined passes straight through, no warning | ||
| emitEnableChannelBindingDeprecationNotice() | ||
| // note: we pass through valid string values to avoid confusion, otherwise | ||
| // "disable" and "require" would both resolve as truthy and mean "prefer" | ||
| return channelBindingLevels.includes(value) ? value : value ? 'prefer' : 'disable' | ||
| } | ||
|
|
||
| function validatedChannelBinding(value) { | ||
| if (!channelBindingLevels.includes(value)) { | ||
| throw new Error(`Invalid channel_binding value: "${value}". Valid values are "disable", "prefer" and "require".`) | ||
| } | ||
| return value | ||
| } | ||
|
|
||
| function resolveChannelBinding(channelBinding, enableChannelBinding) { | ||
| const value = | ||
| channelBinding ?? | ||
| channelBindingFromDeprecatedBoolean(enableChannelBinding) ?? | ||
| process.env.PGCHANNELBINDING ?? | ||
| defaults.channel_binding | ||
|
|
||
| return validatedChannelBinding(value) | ||
| } | ||
|
|
||
| module.exports = { | ||
| channelBindingLevels, | ||
| channelBindingFromDeprecatedBoolean, | ||
| validatedChannelBinding, | ||
| resolveChannelBinding, | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We introduced
Options.useLibpqCompatbecause we had no other way of signaling a change in the parsing behavior. My hope was to removeOptionsonce we made the major version bump.Setting
Options.channelBindingis not changing parsing behavior but instead adding another way to modify the resulting config object.If someone wants to add channel binding, they could parse and then add it to the resulting config object:
If it is to prevent the warning, then:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only use of this new
options.channelBindingparameter is to suppress the warning currently emitted about the forthcoming changed behaviour ofprefer,requireandverify-cawhen channel binding is being enforced.I assume that once the version bump is made, this warning goes away, and thus so does the need to suppress it? So we won't need
options.channelBindingany more, and this shouldn't stop you removingOptions, right?Or have I missed something?