-
-
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.
parametrize service principal and host
- Loading branch information
1 parent
93f30ed
commit 9c052dc
Showing
2 changed files
with
6 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ var Query = require('./query') | |
var defaults = require('./defaults') | ||
var Connection = require('./connection') | ||
const crypto = require('./crypto/utils') | ||
const kerberos = require('kerberos').Kerberos | ||
|
||
class Client extends EventEmitter { | ||
constructor(config) { | ||
|
@@ -20,6 +21,7 @@ class Client extends EventEmitter { | |
this.database = this.connectionParameters.database | ||
this.port = this.connectionParameters.port | ||
this.host = this.connectionParameters.host | ||
this.principal = this.connectionParameters.principal | ||
|
||
// "hiding" the password so it doesn't show up in stack traces | ||
// or if the client is console.logged | ||
|
@@ -204,8 +206,7 @@ class Client extends EventEmitter { | |
|
||
async _handleGSSInit(msg) { | ||
try { | ||
// TODO: Below needs to be parameterized | ||
this.client = await kerberos.initializeClient('[email protected]', { | ||
this.client = await kerberos.initializeClient(`${this.principal}@${this.host}`, { | ||
mechOID: kerberos.GSS_MECH_OID_SPNEGO, | ||
}) | ||
|
||
|
@@ -226,7 +227,7 @@ class Client extends EventEmitter { | |
|
||
// TODO: probably a better way to handle this. | ||
if (token == null) { | ||
return | ||
this.emit('error', 'Received null GSSAPI token on continue') | ||
} | ||
const buf = Buffer.from(token, 'base64') | ||
this.connection.sendBinaryPassword(buf) | ||
|
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