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

V2.x sha2pass draft3 #4258

Merged
merged 42 commits into from
Feb 26, 2024
Merged

V2.x sha2pass draft3 #4258

merged 42 commits into from
Feb 26, 2024

Conversation

renecannao
Copy link
Contributor

No description provided.

1st commit for refactoring the authentication module
Previous commit (2nd refactoring of process_pkt_handshake_response) didn't compile with clickhouse
This branch has code where SHA1_ functions were still used.
New MySQL variable default_authentication_plugin accepting two possible values:
* mysql_native_password
* caching_sha2_password
Using `enum proxysql_auth_plugins` to define mysql authentication plugins.

Also fixed few bugs introduced in previous commits.
Implementation not completed yet, but functional.
It allows connections in which the user password is saved in clear password.
Now mysql_users.password can store the authentication_string as
in MySQL's mysql.user table.

Note: this commit also changes SALT_LEN_MAX in SHA-crypt code from
16 to 20 because MySQL caching_sha2_password uses 20 bytes salt
Extended account_details_t to also store clear_text_password if client
provides it during a full authentication in caching_sha2_password .

De facto, this implements the "caching" part of caching_sha2_password .
…type

Because of the implementation of caching_sha2_password, values of switching_auth_type
are shifted by 1
lib/sha256crypt.cpp Fixed Show fixed Hide fixed
@mirostauder
Copy link
Collaborator

retest this please

2 similar comments
@mirostauder
Copy link
Collaborator

retest this please

@mirostauder
Copy link
Collaborator

retest this please

Also added few FIXME to review part of the code
@mirostauder
Copy link
Collaborator

retest this please

Modified generate_one_byte_pkt() to prefix the data with 1 byte.

This is the "equivalent" of what MySQL performs in
wrap_plguin_data_into_proper_command() , prefixing the data with
a command
@renecannao
Copy link
Contributor Author

Retest this please

During first 'caching_sha2_password' login, 'clear_text_password' is
unknown until authentication is completed. Info previously fetched from
'MySQL_Authentication' should be amended with the received password.
Auth 'caching_sha2_password' imposses and async flow on several
previously sync functions. This new async flow needs to take into
account the potential allocations for 'MySQL_Session' attributes and
client connection userinfo.
Improved observability for auth switch performed during authentication.
The new field 'switching_auth_sent' is only updated when an actual auth
switch requested to the client.
During an full 'caching_sha2_password' auth, it's possible that the pass
has been updated in 'GloMyAuth'. If this possibility is not taking into
account buffer over-read could take place and valid auth attempts
denied.
Added test aims to check the correctness and completion of the currently
supported authentication methods. In this initial version checks:

- clear_text_pass
- mysql_native_password
- caching_sha2_password
- Changed several hardcoded variables in favor of env vars.
- Adopted 'TAP_' convention for env vars.
- Added new file 'test_auth_methods-t.env'.
@renecannao renecannao merged commit b7f53c1 into v2.x Feb 26, 2024
320 of 321 checks passed
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.

3 participants