-
-
Notifications
You must be signed in to change notification settings - Fork 603
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
insecureAuth support (was: bad handshake) #30
Comments
I should note that the same code works with the 'mysql' module. |
Thanks, Brian. can't confirm it on osx/mysql 5.6.10
|
It happens with any schema. It may have something to do with 'insecureAuth' ? |
probably. I think this makes client connect with no PROTOCOL_41 flag. Which version of mysql2 are you using? Is that from npm or git master? |
npm |
Still can't reproduce, and I'm sure I don't support insecure auth at the moment (flag is ignored) |
Do you have this error if you comment out |
also this is what I have:
|
It looks like insecureAuth doesn't do anything currently. Grep returns:
|
you are right, it is ignored. Not sure why your connection fails though |
I created a new user using the new password format and that connected fine. |
I changed the caption. Will close this issue once pre insecure auth is supported. Current problems: |
I am trying to switch from using mysqljs/mysql to mysql2@1.5.1 but unfortunately I can't because |
@midnightcodr does your server support plugin authentication / authentication switch ? ( if you connect with If yes, insecureAuth can be added as authentication switch plugin via config ( and I'd like to make this to happen automatically when |
@sidorares |
@midnightcodr at the moment it's not very trivial. You'll need to port this code https://github.com/mysqljs/mysql/blob/3f371ca18a46150fc1fe1b8bb31a099b9f62f2fb/lib/protocol/Auth.js#L37-L152 and put it into handler similar to implementation for mysql_clear_plugin in #438 (comment) |
this is also relevant - #504 one problem could be that plugin name is reported as empty string - can you verify this? ( add console log in auth switch handler ) |
I got
with |
ok cool. So what you need to add is function(data, cb) {
if (data.pluginName === 'mysql_old_password') {
cb(null, authenticateMysqlOldPassword(yourPassword, data.pluginData))
}
} where authenticateMysqlOldPassword is code similar to https://github.com/mysqljs/mysql/blob/3f371ca18a46150fc1fe1b8bb31a099b9f62f2fb/lib/protocol/Auth.js#L37-L152 |
this is how it's used in mysqljs/mysql: https://github.com/mysqljs/mysql/blob/e8fea7068476ac65d78532bbf786d6393502f54b/lib/protocol/sequences/Handshake.js#L124 So basically to test you can copy/paste whole Auth.js to your code, require it and have handler like this: function(data, cb) {
if (data.pluginName === 'mysql_old_password') {
cb(null, Auth.scramble323(data.pluginData, password))
}
} |
You meant |
Never mind, just saw your new comment after I posted mine. |
that's ok, they don't look newbie at all! |
Got it working. Can't thank you enough @sidorares for your help. |
great! you you think you can find time to port this to mysql2 core that would be great! Pseudo code:
Don't be stressed if you don't have time or experience to do this, in that case these are notes to future me |
Would definitely give it a try. |
maybe would be good to allow and bundle switch handler plugin for |
@sidorares I am getting an empty
|
you mentioned earlier that you getting |
@sidorares sorry my bad. I am getting empty pluginName in the The mysql server version I am testing against is 5.6.20. I am using the following code to do a quick test: const mysql = require('./promise')
// previously defined host, user, password & database
const opts = { host, user, password, database, insecureAuth: true}
const run = async() => {
const conn = await mysql.createConnection(opts)
const [rows, fields] = await conn.query('select 100 as result')
console.log(rows)
await conn.end()
}
run() I have forked the repo on another computer but I was not able to commit due to a linting issue. Will show you the changes to the files you mentioned once I am able to commit and push my code. |
Pulling my hair out but I can't figure out even the simplest update I made can't pass pre-commit. To replicate: |
@midnightcodr which version of prettier gets installed after you do |
Somehow the version installed (1.9.2) is different to what states in package (and -lock).json. More strangely I can't uninstall npm uninstall prettier Which returns
|
@sidorares |
@nwohaibi this is currently relatively low priority for me ( adding insecure 323 password ). Though if we can find reliable way to handle this via authPlugins that would be good. I'll need instructions to replicate this from scratch ( ideally image on docker hub? ) to progress on this |
Output: 'Query error: Bad handshake'
Server: MySQL server 5.0.95 (Linux)
Code:
The text was updated successfully, but these errors were encountered: