TBD54566975 / dwn-server

DWN server - host anywhere publicly accessible for DIDs to use
Apache License 2.0
40 stars 41 forks source link

Unable to provide username and password in postgresql connection URI #106

Open tangentus opened 8 months ago

tangentus commented 8 months ago

When executing DS_PORT=3001 DWN_STORAGE=postgres://postgres:postgres@0.0.0.0:5432/dwn npm run server an error log is given. After checking my postgres logs it seems that the underlying postgres driver is defaulting to the $USER environment variable when connecting to the database instead of the username provided in the connection URI.

Node version: Node.js v18.19.0 Package version: latest (main)

Note That you can get it working by setting the PGUSER and PGPASSWORD environment variables and leave them out of the connection URI. This took a bit of digging to figure out which env variables are being looked for 😓 PGUSER=postgres PGPASSWORD=postgres DS_PORT=3001 DWN_STORAGE=postgres://0.0.0.0:5432/dwn npm run server

/Users/noone/src/dwn-server/node_modules/pg-pool/index.js:45
    Error.captureStackTrace(err);
          ^

Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
    at /Users/noone/src/dwn-server/node_modules/pg-pool/index.js:45:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresDriver.acquireConnection (file:///Users/noone/src/dwn-server/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:19:24)
    at async RuntimeDriver.acquireConnection (file:///Users/noone/src/dwn-server/node_modules/kysely/dist/esm/driver/runtime-driver.js:44:28)
    at async DefaultConnectionProvider.provideConnection (file:///Users/noone/src/dwn-server/node_modules/kysely/dist/esm/driver/default-connection-provider.js:8:28)
    at async DefaultQueryExecutor.executeQuery (file:///Users/noone/src/dwn-server/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at async CreateTableBuilder.execute (file:///Users/noone/src/dwn-server/node_modules/kysely/dist/esm/schema/create-table-builder.js:315:9)
    at async RegistrationStore.initialize (file:///Users/noone/src/dwn-server/dist/esm/src/registration/registration-store.js:20:9)
    at async RegistrationStore.create (file:///Users/noone/src/dwn-server/dist/esm/src/registration/registration-store.js:16:9)
    at async RegistrationManager.create (file:///Users/noone/src/dwn-server/dist/esm/src/registration/registration-manager.js:62:35)