prisma: `Error querying the database: Unknown authentication plugin 'mysql_clear_password'.`
Problem
Getting “Error querying the database: Unknown authentication plugin `mysql_clear_password’.” when trying to connect to an AWS RDS proxy (I can connect fine in other clients with proxy and I can connect fine with prisma directly to the database).
Think its because you have to send the password a certain way when using the mysql_clear_password plugin
Suggested solution
I couldn’t find where we make mysql connections in the project (didn’t spend a lot of time looking), but we need add a way to switch auth when making a connection.
mysql2 has the ability to do this with the authPlugins or on the connection config itself as authSwitchHandler. See below which I got from here https://gist.github.com/btbytes/cf1a1e4a90582924833f4d0a15acc1e9
connectionConfig.authSwitchHandler = (data, cb) => {
if (data.pluginName === 'mysql_clear_password') {
// See https://dev.mysql.com/doc/internals/en/clear-text-authentication.html
console.log("pluginName: "+data.pluginName);
let password = token + '\0';
let buffer = Buffer.from(password);
cb(null, password);
}
};
I don’t think there is alternative solution using prisma
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 4
- Comments: 25 (7 by maintainers)
Commits related to this issue
- feat(client): added enable cleartext plugin to mysql docker env variables Closes #10304 — committed to MohamedAkl1/prisma by deleted user 3 years ago
- feat(client): added enable cleartext plugin to mysql docker env variables Closes #10304 — committed to MohamedAkl1/prisma by MohamedAkl1 3 years ago
- feat(client): added enable cleartext plugin to mysql docker env variables Closes #10304 — committed to MohamedAkl1/prisma by MohamedAkl1 3 years ago
- feat(url): Support for enable_cleartext_plugin param, fix prisma/prisma#10304 — committed to dengfuping/mysql_async by blackbeam 4 years ago
- chore(deps): Use custom mysql_async to support enable_cleartext_plugin, fix prisma/prisma#10304 — committed to dengfuping/prisma-engines by dengfuping 2 years ago
- chore(deps): Use custom mysql_async to support enable_cleartext_plugin, fix prisma/prisma#10304 — committed to dengfuping/prisma-engines by dengfuping 2 years ago
It seems to me the vendored openssl branch at https://github.com/prisma/mysql_async/tree/vendored-openssl is already 110 commits behind master of https://github.com/blackbeam/mysql_async so even though the relevant commit https://github.com/blackbeam/mysql_async/commit/2842af3595c2e30fe97bf2208ce31bb9cc5ed114 which would allow you to do
mysql://localhost/db?enable_cleartext_plugin=truehappened around 1.5 years ago, it’s not available in Prisma. So Prisma can not be used with AWS, at least in the AWS RDS IAM configuration.There is also another issue already fixed in upstream (https://github.com/prisma/prisma/issues/24010). So I think it would be good to update the fork to the latest version. Or even re-evaluate if the fork is really necessary. I have a hard time seeing how exactly the Rust code ends up in the final package and how to verify changes in mysql_async together with Prisma.
Is there any updates? I am currently trying to connect to aws rds via iam auth. And I got
I understand
mysql_clear_passwordis not supported yet in inner engine of prisma. Maybe the error message is from here. https://github.com/prisma/mysql_async/blob/master/src/conn/mod.rs#L461 https://github.com/prisma/mysql_async/blob/0778dea4c9a9f851ff41753e92208dcdf3824c40/src/error.rs#L145I am searching alternative way to query aws rds via iam auth in prisma.
Via https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_enable-cleartext-plugin it seems that one has to start MySQL with
--enable-cleartext-plugin, or via https://dev.mysql.com/doc/refman/8.0/en/cleartext-pluggable-authentication.html setting the env varLIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1might also be enough. So maybe a change here is enough: https://github.com/prisma/prisma/blob/dcbc3c3b3204650c45ce8cb9c1bfbccd3cb2527c/docker/docker-compose.yml#L59-L64NP, let me create a reproduce dockerfile.
We are running into this too, trying to connect to RDS using IAM authentication, which also requires
--enable-cleartext-plugin. (See https://aws.amazon.com/premiumsupport/knowledge-center/users-connect-rds-iam/)@cmonaghan1 unfortunately I never did. I switched to another framework for my needs that let use an authPlugin in mysql2 (which lets me use clear text auth)
If there is a way in prisma to manually create the connection and also change the authentication then that would solve it I think (I think prisma def supports mysql2 so it should be possible).