Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password authentication fails and server fails to connect to database #7778

Closed
4 tasks done
pmmlo opened this issue Jan 17, 2022 · 10 comments
Closed
4 tasks done

Password authentication fails and server fails to connect to database #7778

pmmlo opened this issue Jan 17, 2022 · 10 comments
Labels
type:question Support or code-level question

Comments

@pmmlo
Copy link

pmmlo commented Jan 17, 2022

New Issue Checklist

Issue Description

From pre-release 5.0.0-alpha.16 to 5.0.0-alpha.17, I get the following critical error: error: password authentication failed for user "X", using PostgreSQL 14.x with enforced TLS.

Steps to reproduce

  1. Setup a base Express Server setup.
  2. Run Parse, GraphQL, and LiveQuery servers.
  3. Confirmation all servers are started without issue.
  4. Error occurs following the start of the servers.

Actual Outcome

error: password authentication failed for user "X" and server fails to connect to database.

Expected Outcome

No error. Successful connection to database.

Environment

PostgreSQL 14.x with TLS enforced.

Server

  • Parse Server version: 5.0.0-alpha.17
  • Operating system: Dockers on unix
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): Postgres
  • Database version: 14.x
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JS
  • SDK version: Default in version.

Logs

error: password authentication failed for user "X" and server fails to connect to database.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Jan 17, 2022

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@ThornWu
Copy link
Contributor

ThornWu commented Jan 17, 2022

Did the client correctly being initialized before using it?

const allControllers = controllers.getControllers(options);

const databaseController = getDatabaseController(options);

databaseAdapter = getDatabaseAdapter(databaseURI, collectionPrefix, databaseOptions);

return new PostgresStorageAdapter({
uri: databaseURI,
collectionPrefix,
databaseOptions,
});

const { client, pgp } = createClient(uri, databaseOptions);
this._client = client;

async getAllClasses() {
return this._client.task('get-all-classes', async t => {
return await t.map('SELECT * FROM "_SCHEMA"', null, row =>
toParseSchema({ className: row.className, ...row.schema })
);
});
}

@mtrezza mtrezza changed the title v5.0.0-alpha.17: error: password authentication failed for user "X" and server fails to connect to database. Password authentication fails for user "X" and server fails to connect to database Jan 17, 2022
@mtrezza mtrezza changed the title Password authentication fails for user "X" and server fails to connect to database Password authentication fails and server fails to connect to database Jan 17, 2022
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Jan 17, 2022
@mtrezza
Copy link
Member

mtrezza commented Jan 17, 2022

From pre-release 5.0.0-alpha.16 to 5.0.0-alpha.17, I get the following critical error

Just to confirm, you do not get that error with 5.0.0-alpha.15?

@mtrezza mtrezza added the block:release Needs to be resolved before next release on release branch; remove label afterwards label Jan 17, 2022
@pmmlo
Copy link
Author

pmmlo commented Jan 17, 2022

Just to confirm, you do not get that error with 5.0.0-alpha.15?

I actually checked 5.0.0-alpha.16. Works without issue. I also tried 5.0.0-alpha.18 with the change manually reverted and no issue.

@mtrezza
Copy link
Member

mtrezza commented Jan 22, 2022

@pmmlo would you please try to write a failing test for this issue? this is currently blocking the Parse Server 5 release, so it would be great if we could solve this within the next few days. being able to reproduce this would be an important first step. if we cannot reproduce this issue, we can't fix it and we'd assume that it's a custom code issue in your environment, so we'd make a release with this uncertainty.

If you cannot reproduce this with a test, I'd just set a breakpoint for the auth error and then go back step-by-step in the caller chain to find the issue. You could also compare the behavior this way for both, the working code without the change in #7678 and the failing code with the change.

Referencing your comment as it contains some more details.

@mtrezza mtrezza pinned this issue Jan 22, 2022
@pmmlo
Copy link
Author

pmmlo commented Jan 22, 2022

@pmmlo would you please try to write a failing test for this issue? this is currently blocking the Parse Server 5 release, so it would be great if we could solve this within the next few days. being able to reproduce this would be an important first step. if we cannot reproduce this issue, we can't fix it and we'd assume that it's a custom code issue in your environment, so we'd make a release with this uncertainty.

If you cannot reproduce this with a test, I'd just set a breakpoint for the auth error and then go back step-by-step in the caller chain to find the issue. You could also compare the behavior this way for both, the working code without the change in #7678 and the failing code with the change.

Referencing your comment as it contains some more details.

In that case, I suggest just proceeding with the community plan. I'm just reporting bugs and issues that I think could potentially become bigger problems. At least now, we know a similar db auth error in the future could stem from this seemingly unrelated line.

I think this most certainly could be an implementation case.

For example, in the test environment, I enforced strict TLS to authenticate postgres. In a production environment, I think that should be done for most cases but understand not everyone can/does. Could also be other configurations in postgres, firewall ports, private network...

If I'm the only one running into this issue, I say just send it. Worst case is it becomes a widespread issue and we just revert that line in the future (low chance of merge conflict).

@mtrezza Cheers for looking into the issue with me.

@pmmlo pmmlo closed this as completed Jan 22, 2022
@pmmlo
Copy link
Author

pmmlo commented Jan 22, 2022 via email

@mtrezza
Copy link
Member

mtrezza commented Jan 23, 2022

@pmmlo just before we close this issue, could you help me trying to reproduce this?

Does this issue occur also without GraphQL and LiveQuery servers and only a fresh, plain install of Parse Server connected to PostgreSQL 14.x with TLS enforced? And if you turn off TLS does the issue go away?

@mtrezza mtrezza reopened this Jan 23, 2022
@pmmlo
Copy link
Author

pmmlo commented Jan 23, 2022 via email

@mtrezza
Copy link
Member

mtrezza commented Jan 23, 2022

I see, then let's assume for now that it's an env specific issue, close it and release Parse Server 5. We can try to keep this in mind in case related issues pop up in the next couple of weeks after v5 release. In case you find the time to try to reduce this issue down to a simple deployment of Parse Server that one can reproduce locally, we can pick this up again, but in any case I expect we'd get feedback if this is really a server bug.

@mtrezza mtrezza closed this as completed Jan 23, 2022
@mtrezza mtrezza added type:question Support or code-level question and removed type:bug Impaired feature or lacking behavior that is likely assumed block:release Needs to be resolved before next release on release branch; remove label afterwards labels Jan 23, 2022
@mtrezza mtrezza unpinned this issue Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

3 participants