4

I'm currently running openSuse on an rPi3B+ (aarch64) and have hit a wall running a NodeJS connection script.

I went through the standard install of PostgreSQL (v10 is what is offered on this version of openSuse) then created a new role with

CREATE ROLE new_role LOGIN PASSWORD 'passwd';

and then a db with

CREATE DATABASE new_db OWNER new_role;

Both the \l & \du return the expected outputs show that both the role and db have been created successfully with the correct owner.

So I then quickly created a node project directory and copied the test script from the docs: https://node-postgres.com/features/connecting

const { Pool, Client } = require('pg')
const connectionString = 'postgresql://new_role:passwd@localhost:5432/new_db'

const pool = new Pool({
  connectionString: connectionString,
})

pool.query('SELECT NOW()', (err, res) => {
  console.log(err, res)
  pool.end()
})

const client = new Client({
  connectionString: connectionString,
})
client.connect()

client.query('SELECT NOW()', (err, res) => {
  console.log(err, res)
  client.end()
})

This returns a few broken promise errors that I haven't caught(.cath()) correctly yet, and an error code of 28000 that looks like this:

{ error: Ident authentication failed for user "new_role"
at Connection.parseE (/home/eru/postgresDB/node_modules/pg/lib/connection.js:554:11)
at Connection.parseMessage (/home/eru/postgresDB/node_modules/pg/lib/connection.js:379:19)
at Socket.<anonymous> (/home/eru/postgresDB/node_modules/pg/lib/connection.js:119:22)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  name: 'error',
  length: 99,
  severity: 'FATAL',
  code: '28000',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'auth.c',
  line: '328',
  routine: 'auth_failed' } undefined

So I'm pretty sure the attempt made it to the intended port otherwise I wouldn't have received the detailed error in terminal. The error code = invalid_authorization_specification

Is the there something I need to do on the server ,psql interface, that will fulfill the authorization specification?

When I've looked into that specific one I can't seem to find useful search results relevant to my situation.

Fairly new to postgres here so I'm sure this is a pretty noob mistake that I'm missing but any help or input is very appreciated!

AustinFoss
  • 385
  • 5
  • 13

1 Answers1

4

Found an answer after a little more digging here: error: Ident authentication failed for user

Ended up editing my pg_hba.conf from the ident method to md5

This is rather crude because I don't really understand what I changed aside from telling postgreSQL to check the md5 encrypted password instead of checking if my username matched the roles created on the server.

If anyone has a proper explanation for what's changed and why I'm all ears.

AustinFoss
  • 385
  • 5
  • 13