Skip to content

Commit

Permalink
parametrize service principal and host
Browse files Browse the repository at this point in the history
handle accept token

return if no token step
  • Loading branch information
albertchang committed Aug 29, 2024
1 parent 9c13cc4 commit 038860c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/pg/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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,
})

Expand Down
2 changes: 2 additions & 0 deletions packages/pg/lib/connection-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class ConnectionParameters {

this.port = parseInt(val('port', config), 10)
this.host = val('host', config)
// Kerberos/GSSAPI service principal
this.principal = val('principal', config)

// "hiding" the password so it doesn't show up in stack traces
// or if the client is console.logged
Expand Down

0 comments on commit 038860c

Please sign in to comment.