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

Use caching_sha2_password for proxy auth #24

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

dbussink
Copy link
Contributor

@dbussink dbussink commented Oct 9, 2024

Up until now, mysql_native_password was used for auth. This is however removed in MySQL 9.x and this is the default that Homebrew installs on MacOS.

While we can also try to deal with installing older versions on MacOS, alternatively we update the auth for the proxy to
caching_sha2_password.

The one thing that this breaks is very old MySQL 5.7 clients. Anything older than MySQL 5.7.23 (released 2018-07-27) would break with this. We don't really support 5.7 for the proxy anyway though.

Up until now, mysql_native_password was used for auth. This is however
removed in MySQL 9.x and this is the default that Homebrew installs on
MacOS.

While we can also try to deal with installing older versions on MacOS,
alternatively we update the auth for the proxy to
caching_sha2_password.

The one thing that this breaks is very old MySQL 5.7 clients. Anything
older than MySQL 5.7.23 (released 2018-07-27) would break with this. We
don't really support 5.7 for the proxy anyway though.

Signed-off-by: Dirkjan Bussink <[email protected]>
return nil, err
}

// Salt must be a legal UTF8 string.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the salt generation to not be uniformly random. It may be better to just hex encode the randomly generated bytes, so we get a uniform random string still.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not matter in practice since it's not actually used. I merely copied what is already there in Vitess (and this likely does the same as MySQL). So if this needs fixing, it should be fixed in Vitess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hex encoding btw here is worse entropy wise though. Since it means half the entropy from the original source bytes (10 instead of 20) and the final character set is much smaller then.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, yeh, MySQL does do the same thing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hex encoding btw here is worse entropy wise though. Since it means half the entropy from the original source bytes (10 instead of 20) and the final character set is much smaller then.

Not if all 40 characters are used. 20 bytes worth of entropy, but actually uniformly random.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell It is not possible to use more characters. This is hardcoded to 20 in the MySQL protocol. There's no flexibility here afaik.

Heh, yeh, MySQL does do the same thing.

Yeah, so not something we will change here or in Vitess then. If you think it's worth it, you could report it to MySQL then.

Copy link
Member

@iheanyi iheanyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbussink dbussink merged commit 7fdfa92 into main Oct 9, 2024
1 check passed
@dbussink dbussink deleted the dbussink/implement-caching-sha2-auth branch October 9, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants