Skip to content

Implement caching_sha2_password for mysql 8+#165

Merged
eileencodes merged 4 commits intomainfrom
caching_sha2_password
Mar 21, 2024
Merged

Implement caching_sha2_password for mysql 8+#165
eileencodes merged 4 commits intomainfrom
caching_sha2_password

Conversation

@eileencodes
Copy link
Member

@eileencodes eileencodes commented Mar 12, 2024

This PR implements caching_sha2_password for mysql 8. Note that we have
chosen on purpose to only implement the path where TLS or a unix socket is used. We will
not be implementing the non-TLS/non-unix socket path.

Co-authored-by: John Hawthorn john@hawthorn.email
Co-authored-by: Aaron Patterson (tenderlove) tenderlove@ruby-lang.org

Fixes: #26


For testing:

Point trilogy at this branch in your Gemfile:

gem "trilogy", github: "trilogy-libraries/trilogy", branch: "caching_sha2_password", glob: "contrib/ruby/*.gemspec"

Update your mysql auth plugin / policy to use caching_sha2_password over mysql_native_password

@eileencodes eileencodes force-pushed the caching_sha2_password branch 6 times, most recently from 5417986 to 04d407b Compare March 13, 2024 15:16
@eileencodes eileencodes marked this pull request as ready for review March 13, 2024 15:16
@eileencodes eileencodes changed the title Add failing test for caching_sha2_password auth Implement caching_sha2_password for mysql 8+ Mar 13, 2024
@eileencodes eileencodes force-pushed the caching_sha2_password branch from 96b52a4 to adf593a Compare March 13, 2024 15:46
@jhawthorn jhawthorn force-pushed the caching_sha2_password branch from bb69dff to db62763 Compare March 13, 2024 17:15
@eileencodes eileencodes force-pushed the caching_sha2_password branch from fb277a9 to febaaa9 Compare March 13, 2024 17:35
eileencodes and others added 2 commits March 13, 2024 14:03
caching_sha2 username should only run against that 8.0, otherwise it
fails in 5.7.

Co-authored-by: John Hawthorn <john@hawthorn.email>
This PR implements caching_sha2_password for mysql 8. Note that we have
chosen on purpose to only implement the path where TSL is used. We will
not be implementing the non-TSL path.

Co-authored-by: John Hawthorn <john@hawthorn.email>
Co-authored-by: Aaron Patterson (tenderlove) <tenderlove@ruby-lang.org>
brew services start mysql@${{ matrix.mysql }}
sleep 5
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test'
[[ "$MYSQL_VERSION" == "8.0" ]] && $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < docker-entrypoint-initdb.d/caching_sha2_password_user.sql
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be any 8.x version and later? Since we also have versions up to 8.3.0 today for MySQL and each quarter there's a new one.

Copy link
Member Author

@eileencodes eileencodes Mar 18, 2024

Choose a reason for hiding this comment

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

This is the image name and we don't have a matrix for 5.7, 8.0, and 8.3, just 5.7 and 8.0. If we added 8.3 and then this wasn't updated, the build would fail. I'm not against doing a >= but it's also not broken currently. 🤷🏼‍♀️

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, this was more future proofing.

Copy link
Collaborator

@composerinteralia composerinteralia left a comment

Choose a reason for hiding this comment

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

One thought about the "unsupported" error class, but otherwise makes sense to me.

We aren't supporting `caching_sha2_password` in Trilogy unless mysql is
running with TLS or a unix socket, so raise an error if using
`caching_sha2_password` in that case.
@eileencodes eileencodes merged commit 8a951e4 into main Mar 21, 2024
@eileencodes eileencodes deleted the caching_sha2_password branch March 21, 2024 18:34
eileencodes added a commit that referenced this pull request Mar 21, 2024
composerinteralia added a commit that referenced this pull request Mar 21, 2024
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.

Having caching_sha2_password authentication issues with mysql 8.0.30

4 participants