public inbox for [email protected]help / color / mirror / Atom feed
Application trying to use wrong user when logging into the database 6+ messages / 3 participants [nested] [flat]
* Application trying to use wrong user when logging into the database @ 2021-03-28 13:44 Simon Connah <[email protected]> 0 siblings, 2 replies; 6+ messages in thread From: Simon Connah @ 2021-03-28 13:44 UTC (permalink / raw) To: [email protected] <[email protected]> Hi, I'm writing a web app using Node.js and pg-promise along with PostgreSQL. I've been following the documentation to connect to the database found here: https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax#configuration-object and have all the right data supplied. But instead of using my applications role which I created in PostgreSQL it is trying to use my Linux user name "simon" and is failing authentication because of it. I'm just confused at the moment. At no point in time have I created a role called "simon" and I have never tried to connect to any of my databases using the role name "simon", so why is it trying to authenticate as "simon"? Sorry if this is a silly question but it has me completely stumped. Simon. Attachments: [application/pgp-signature] signature.asc (249B, ../../Wt5eqfXFsGBGpT6_-YFFDGuTpOheH21XUc2vodexpEarm11iuomdcCPCOhtJvUnMg35WVoWz72d7tpMmyvdJN-3WGqayIThKQlAFyxVrKRU=@protonmail.com/2-signature.asc) download ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Application trying to use wrong user when logging into the database @ 2021-03-28 14:00 Bzzzz <[email protected]> parent: Simon Connah <[email protected]> 1 sibling, 1 reply; 6+ messages in thread From: Bzzzz @ 2021-03-28 14:00 UTC (permalink / raw) To: [email protected]; +Cc: Simon Connah <[email protected]> On Sun, 28 Mar 2021 13:44:59 +0000 Simon Connah <[email protected]> wrote: Hi, > But instead of using my > applications role which I created in PostgreSQL it is trying to use my > Linux user name "simon" and is failing authentication because of it. > I'm just confused at the moment. At no point in time have I created a > role called "simon" and I have never tried to connect to any of my > databases using the role name "simon", so why is it trying to > authenticate as "simon"? Read this and check you're not in this case : https://www.dbrnd.com/2016/12/postgresql-pg_ident-conf-to-map-operating-system-username-and-database... Jean-Yves ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Application trying to use wrong user when logging into the database @ 2021-03-28 14:21 Simon Connah <[email protected]> parent: Bzzzz <[email protected]> 0 siblings, 1 reply; 6+ messages in thread From: Simon Connah @ 2021-03-28 14:21 UTC (permalink / raw) To: Bzzzz <[email protected]>; +Cc: [email protected] ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Sunday, March 28th, 2021 at 15:00, Bzzzz <[email protected]> wrote: > On Sun, 28 Mar 2021 13:44:59 +0000 > > Simon Connah [email protected] wrote: > > Hi, > > > But instead of using my > > > > applications role which I created in PostgreSQL it is trying to use my > > > > Linux user name "simon" and is failing authentication because of it. > > > > I'm just confused at the moment. At no point in time have I created a > > > > role called "simon" and I have never tried to connect to any of my > > > > databases using the role name "simon", so why is it trying to > > > > authenticate as "simon"? > > Read this and check you're not in this case : > > https://www.dbrnd.com/2016/12/postgresql-pg_ident-conf-to-map-operating-system-username-and-database... > > Jean-Yves Thank you for your reply. My pg_ident.conf file is completely empty (well all commented out at least). Do you really need to map a Linux system user to a PostgreSQL role to get this to work? Seems like a bit of a hack to me. I'm probably missing something simple again. I don't need external access to the database at the moment, although it is helpful knowledge to have for the future. This is all on my local machine so I've set pg_hba.conf to md5 for 127.0.0.1/32 which I assumed would just make it work. Simon. Attachments: [application/pgp-signature] signature.asc (249B, ../../b9nwO9kDTQIb4LQmDtlpoRAaYMluRMZRNB3p1S5VyP8DXU7KEZ8H7e9krts_j1LLCfViul__c0rfv2EnIPXuvI8a1Dk0V3FobGGeNmxFuHA=@protonmail.com/2-signature.asc) download ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Application trying to use wrong user when logging into the database @ 2021-03-28 14:44 Bzzzz <[email protected]> parent: Simon Connah <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Bzzzz @ 2021-03-28 14:44 UTC (permalink / raw) To: [email protected] On Sun, 28 Mar 2021 14:21:29 +0000 Simon Connah <[email protected]> wrote: Rahhhh, it was sent directly to you instead of the ML :((( re-sending it. > > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ > > On Sunday, March 28th, 2021 at 15:00, Bzzzz <[email protected]> wrote: > > > On Sun, 28 Mar 2021 13:44:59 +0000 > > > > > Simon Connah [email protected] wrote: > > > > > Hi, > > > > > > But instead of using my > > > > > > > applications role which I created in PostgreSQL it is trying to > > > use my > > > > > > > Linux user name "simon" and is failing authentication because of > > > it. > > > > > > > I'm just confused at the moment. At no point in time have I > > > created a > > > > > > > role called "simon" and I have never tried to connect to any of my > > > > > > > databases using the role name "simon", so why is it trying to > > > > > > > authenticate as "simon"? > > > > > Read this and check you're not in this case : > > > > > https://www.dbrnd.com/2016/12/postgresql-pg_ident-conf-to-map-operating-system-username-and-database... > > > > > Jean-Yves > > Thank you for your reply. My pg_ident.conf file is completely empty > (well all commented out at least). Do you really need to map a Linux > system user to a PostgreSQL role to get this to work? Seems like a bit > of a hack to me. I'm probably missing something simple again. I don't > need external access to the database at the moment, although it is > helpful knowledge to have for the future. > > This is all on my local machine so I've set pg_hba.conf to md5 for > 127.0.0.1/32 which I assumed would just make it work. > > Simon. Normal > Do you really need to map a Linux > system user to a PostgreSQL role to get this to work? Not at all, as they have nothing in common, except if you use a system user of course - this looks like just a facility. > Seems like a bit > of a hack to me. I'm probably missing something simple again. I don't > need external access to the database at the moment, although it is > helpful knowledge to have for the future. As your file's empty, this can only come from your app (hehehe), so try to launch it under another user to see if it takes the username of the launcher by default, which seems to be the case (you launched it under the Linux username 'simon', didn't you !?) Check the docs to find what is the behavior of the js Pg driver. Double check your configuration file has the right username _and_ that it is effectively read by your app (trace each steps w/ prints or logs). If nothing works, re-write your app in Cobol ;-p) Jean-Yves ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Application trying to use wrong user when logging into the database @ 2021-03-29 09:47 hubert depesz lubaczewski <[email protected]> parent: Simon Connah <[email protected]> 1 sibling, 1 reply; 6+ messages in thread From: hubert depesz lubaczewski @ 2021-03-29 09:47 UTC (permalink / raw) To: Simon Connah <[email protected]>; +Cc: [email protected] <[email protected]> On Sun, Mar 28, 2021 at 01:44:59PM +0000, Simon Connah wrote: > https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax#configuration-object > > and have all the right data supplied. But instead of using my > applications role which I created in PostgreSQL it is trying to use my > Linux user name "simon" and is failing authentication because of it. > I'm just confused at the moment. At no point in time have I created > a role called "simon" and I have never tried to connect to any of my > databases using the role name "simon", so why is it trying to > authenticate as "simon"? Pg will try to connect as db user simon if you don't provide username to log in as. For example, if I'm logged in shell as depesz, and will try: psql -d xx, it will try to login to db xx as user depesz. To login as user "magic", I have to provide it expliticly: psql -U magic -d xx. Please show us your connection code from your app. Best regards, depesz ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Application trying to use wrong user when logging into the database @ 2021-03-29 14:28 Simon Connah <[email protected]> parent: hubert depesz lubaczewski <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Simon Connah @ 2021-03-29 14:28 UTC (permalink / raw) To: [email protected]; +Cc: [email protected] <[email protected]> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday, March 29th, 2021 at 10:47, hubert depesz lubaczewski <[email protected]> wrote: > On Sun, Mar 28, 2021 at 01:44:59PM +0000, Simon Connah wrote: > > > https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax#configuration-object > > > > and have all the right data supplied. But instead of using my > > > > applications role which I created in PostgreSQL it is trying to use my > > > > Linux user name "simon" and is failing authentication because of it. > > > > I'm just confused at the moment. At no point in time have I created > > > > a role called "simon" and I have never tried to connect to any of my > > > > databases using the role name "simon", so why is it trying to > > > > authenticate as "simon"? > > Pg will try to connect as db user simon if you don't provide username to > > log in as. > > For example, if I'm logged in shell as depesz, and will try: psql -d xx, > > it will try to login to db xx as user depesz. > > To login as user "magic", I have to provide it expliticly: psql -U magic > > -d xx. > > Please show us your connection code from your app. > > Best regards, > > depesz Thank you for your reply. I fixed it. It was a silly mistake on my end where I was not importing the environment variables for database connection information correctly. Simon. Attachments: [application/pgp-signature] signature.asc (249B, ../../NyaDa65fVh5N7Mq3dOkpAnxNr6KUjo4K7x_9lAvglvpPWNig3doYYb1QCPm3kLTNL_xWEK3ax7igWD16NaZSfOIZrLrCI4nwH__AHtLTiYU=@protonmail.com/2-signature.asc) download ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-03-29 14:28 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-03-28 13:44 Application trying to use wrong user when logging into the database Simon Connah <[email protected]> 2021-03-28 14:00 ` Bzzzz <[email protected]> 2021-03-28 14:21 ` Simon Connah <[email protected]> 2021-03-28 14:44 ` Bzzzz <[email protected]> 2021-03-29 09:47 ` hubert depesz lubaczewski <[email protected]> 2021-03-29 14:28 ` Simon Connah <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox