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

Most upvoted comments

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=true happened 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

Error querying the database: Unknown authentication plugin `mysql_clear_password'.

I understand mysql_clear_password is 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#L145

I am searching alternative way to query aws rds via iam auth in prisma.

NP, 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).