-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protoype of kerberos support (non parameterized with TODOs)
- Loading branch information
1 parent
b5281f5
commit 93f30ed
Showing
6 changed files
with
231 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -174,6 +174,10 @@ class Client extends EventEmitter { | |
} | ||
|
||
_attachListeners(con) { | ||
// kerberos | ||
con.on('GSSInit', this._handleGSSInit.bind(this)) | ||
con.on('GSSContinue', this._handleGSSContinue.bind(this)) | ||
|
||
// password request handling | ||
con.on('authenticationCleartextPassword', this._handleAuthCleartextPassword.bind(this)) | ||
// password request handling | ||
|
@@ -198,6 +202,39 @@ class Client extends EventEmitter { | |
con.on('notification', this._handleNotification.bind(this)) | ||
} | ||
|
||
async _handleGSSInit(msg) { | ||
try { | ||
// TODO: Below needs to be parameterized | ||
this.client = await kerberos.initializeClient('[email protected]', { | ||
mechOID: kerberos.GSS_MECH_OID_SPNEGO, | ||
}) | ||
|
||
// TODO: below this might need to be a recursive loop to step multiple times. | ||
const token = await this.client.step('') | ||
|
||
const buf = Buffer.from(token, 'base64') | ||
this.connection.sendBinaryPassword(buf) | ||
} catch (e) { | ||
this.emit('error', e) | ||
} | ||
} | ||
|
||
async _handleGSSContinue(msg) { | ||
try { | ||
const inToken = msg.inToken | ||
const token = await this.client.step(inToken) | ||
|
||
// TODO: probably a better way to handle this. | ||
if (token == null) { | ||
return | ||
} | ||
const buf = Buffer.from(token, 'base64') | ||
this.connection.sendBinaryPassword(buf) | ||
} catch (e) { | ||
this.emit('error', e) | ||
} | ||
} | ||
|
||
// TODO(bmc): deprecate pgpass "built in" integration since this.password can be a function | ||
// it can be supplied by the user if required - this is a breaking change! | ||
_checkPgPass(cb) { | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"author": "Brian Carlson <[email protected]>", | ||
"main": "./lib", | ||
"dependencies": { | ||
"kerberos": "^2.1.0", | ||
"pg-connection-string": "^2.6.4", | ||
"pg-pool": "^3.6.2", | ||
"pg-protocol": "^1.6.1", | ||
|
Oops, something went wrong.