Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit afb7d9d

Browse files
committedJul 3, 2024·
parametrize service principal and host
handle accept token return if no token step
1 parent 93f30ed commit afb7d9d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎packages/pg/lib/client.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var Query = require('./query')
1010
var defaults = require('./defaults')
1111
var Connection = require('./connection')
1212
const crypto = require('./crypto/utils')
13+
const kerberos = require('kerberos').Kerberos
1314

1415
class Client extends EventEmitter {
1516
constructor(config) {
@@ -20,6 +21,7 @@ class Client extends EventEmitter {
2021
this.database = this.connectionParameters.database
2122
this.port = this.connectionParameters.port
2223
this.host = this.connectionParameters.host
24+
this.principal = this.connectionParameters.principal
2325

2426
// "hiding" the password so it doesn't show up in stack traces
2527
// or if the client is console.logged
@@ -204,8 +206,7 @@ class Client extends EventEmitter {
204206

205207
async _handleGSSInit(msg) {
206208
try {
207-
// TODO: Below needs to be parameterized
208-
this.client = await kerberos.initializeClient('postgres@pg.US-WEST-2.COMPUTE.INTERNAL', {
209+
this.client = await kerberos.initializeClient(`${this.principal}@${this.host}`, {
209210
mechOID: kerberos.GSS_MECH_OID_SPNEGO,
210211
})
211212

‎packages/pg/lib/connection-parameters.js

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class ConnectionParameters {
6565

6666
this.port = parseInt(val('port', config), 10)
6767
this.host = val('host', config)
68+
// Kerberos/GSSAPI service principal
69+
this.principal = val('principal', config)
6870

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

0 commit comments

Comments
 (0)
Please sign in to comment.