sequelize / cli

The Sequelize CLI
MIT License
2.53k stars 528 forks source link

Sequelize CLI Fails to Authenticate with Postgres DB Containing a ':' in Password #1388

Closed hrabizadeh-sa closed 10 months ago

hrabizadeh-sa commented 11 months ago

When attempting to use Sequelize CLI to connect to a PostgreSQL database, an issue arises if the database password contains a colon (':') symbol. The CLI does not handle this special character correctly, causing authentication failures.

I'm using the Sequelize db:migration with and without --url and in both scenarios, Sequelize could authenticate to the database with the same password but sequelize-cli can not connect to run migrations and seeds.

In the file config-helper.js at line 174, we've identified that the const urlParts = url.parse(urlString); statement is responsible for decoding encoded URL symbols, including the colon (':'). Due to the following code at line 186, which is password: urlParts.auth.split(':')[1], characters in the password field after the colon (':') will be ignored.

WikiRik commented 11 months ago

This was fixed before (see https://github.com/sequelize/cli/pull/334) but for some reason reverted. I copied the code from the core repo, can you check if that works? We have minimal test coverage and with the upcoming rewrite I'm not sure if I want to invest the time into it now. Only main thing we changed is that I'm not using _.assign anymore

hrabizadeh-sa commented 10 months ago

Hi, I've just reviewed the code and even tested it on the Node console and it seems it is working properly.

Thanks,

github-actions[bot] commented 10 months ago

:tada: This issue has been resolved in version 6.6.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tejasautkar commented 1 month ago

I am still facing the same issue. my password has |{:]r*+) these special characters.