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

server: handle clients without authplugin support #27931

Merged
merged 6 commits into from
Oct 11, 2021

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Sep 9, 2021

What problem does this PR solve?

Issue Number: close #27855

Problem Summary:

Old (MySQL 5.1 and before) clients that don't send authentication plugin info in the login packet were having issues authenticating and/or got an incorrect error message

What is changed and how it works?

  1. The code now checks for mysql.ClientPluginAuth in resp.Capability.
  2. Instead of returning an error it now logs a warning if it encounters an unknown authentication plugin

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Documentation

  • Affects user behaviors
  • Changes MySQL compatibility

Release note

Fixed a bug where MySQL 5.1 and older clients had issues authenticating

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 9, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • morgo
  • sylzd

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 9, 2021
@dveeden
Copy link
Contributor Author

dveeden commented Sep 14, 2021

/cc @morgo @tiancaiamao @time-and-fate

Copy link
Contributor

@morgo morgo left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 14, 2021
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM for the rest of the code, but I'm not an expert of authfication, just want to check if this is expected:

mysql/5.1.30/bin/mysql -u u1 -h 127.0.0.1 -P 4000 -pabc -e QUIT
# OK

mysql/5.1.30/bin/mysql -u u2 -h 127.0.0.1 -P 4000 -pabc -e QUIT
ERROR 1045 (28000): Access denied for user 'u2'@'127.0.0.1' (using password: YES)

mysql/5.1.30/bin/mysql -u u3 -h 127.0.0.1 -P 4000 -pabc -e QUIT
ERROR 1045 (28000): Access denied for user 'u2'@'127.0.0.1' (using password: YES)

(the case from your comment: #27855 (comment))

server/conn.go Outdated Show resolved Hide resolved
@dveeden dveeden force-pushed the authplugin_old_client branch from 3ec9d93 to 013102d Compare September 27, 2021 06:49
@dveeden
Copy link
Contributor Author

dveeden commented Sep 27, 2021

LGTM for the rest of the code, but I'm not an expert of authfication, just want to check if this is expected:

mysql/5.1.30/bin/mysql -u u1 -h 127.0.0.1 -P 4000 -pabc -e QUIT
# OK

User exists, password is correct and authentication method is supported by client and server => OK

mysql/5.1.30/bin/mysql -u u2 -h 127.0.0.1 -P 4000 -pabc -e QUIT
ERROR 1045 (28000): Access denied for user 'u2'@'127.0.0.1' (using password: YES)

Authentication method (caching_sha2_password) is not supported by the client, failing as expected.

mysql/5.1.30/bin/mysql -u u3 -h 127.0.0.1 -P 4000 -pabc -e QUIT
ERROR 1045 (28000): Access denied for user 'u2'@'127.0.0.1' (using password: YES)

Account doesn't exist, failing as expected.

Testing the same against MySQL 8.0.26:

[dvaneeden@dve-carbon tidb]$ ~/opt/mysql/5.1.73/bin/mysql -u u1 -h 127.0.0.1 -P 8026 -pabc -e QUIT
[dvaneeden@dve-carbon tidb]$ ~/opt/mysql/5.1.73/bin/mysql -u u2 -h 127.0.0.1 -P 8026 -pabc -e QUIT
ERROR 1251 (08004): Client does not support authentication protocol requested by server; consider upgrading MySQL client
[dvaneeden@dve-carbon tidb]$ ~/opt/mysql/5.1.73/bin/mysql -u u3 -h 127.0.0.1 -P 8026 -pabc -e QUIT
ERROR 1045 (28000): Access denied for user 'u3'@'localhost' (using password: YES)

So there is a difference between the MySQL behavior and this PR: The error for the second case is different.

@sylzd
Copy link
Contributor

sylzd commented Oct 11, 2021

I've met the same issue by client github.com/ziutek/mymysql/mysql. Plz cherry-pick it on v5.2.X.

Copy link
Contributor

@sylzd sylzd left a comment

Choose a reason for hiding this comment

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

LGTM. Old client should keep the compatibility because many old codes like availability monitors runs online.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 11, 2021
@sylzd
Copy link
Contributor

sylzd commented Oct 11, 2021

@morgo plz help to merge~ 🤣 Then we can skip the v5.2.1 to a new version before putting the cluster into production.

@morgo
Copy link
Contributor

morgo commented Oct 11, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 013102d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 11, 2021
@ti-chi-bot ti-chi-bot merged commit fd42198 into pingcap:master Oct 11, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #28734

dveeden added a commit to ti-srebot/tidb that referenced this pull request Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.2 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tidb returns 'Unknown auth plugin' when some old clients didn't set auth plugin in login request
6 participants