-
-
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
11
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
11 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 887c1ca
Disallow changing channelBinding after Client construction
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, force = false) { | ||
| if (value === undefined && !force) return // pass undefined straight through, no warning, unless forced | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.