MXS-862: Do first part of authentication in MySQLBackend
The first message exchange between the server and the client will almost always contain the same data. If the server is going to change authentication methods, it will send an AuthSwitchRequest packet instead of the OK/ERR packet that it would normally send. Only after this point the authenticator modules actually need to do something. In the case of the default 'mysql_native_password' plugin, the only thing that the plugin needs to do is to check whether the server responded with an OK packet.
This commit is contained in:
@ -580,10 +580,25 @@ gw_read_backend_event(DCB *dcb)
|
||||
log_error_response(dcb, readbuf);
|
||||
}
|
||||
|
||||
if (proto->protocol_auth_state == MXS_AUTH_STATE_CONNECTED ||
|
||||
proto->protocol_auth_state == MXS_AUTH_STATE_RESPONSE_SENT)
|
||||
if (proto->protocol_auth_state == MXS_AUTH_STATE_CONNECTED)
|
||||
{
|
||||
/** Read the first message from the server */
|
||||
mxs_auth_state_t state = MXS_AUTH_STATE_FAILED;
|
||||
|
||||
/** Read the server handshake and send the standard response */
|
||||
if (gw_read_backend_handshake(dcb, readbuf))
|
||||
{
|
||||
state = gw_send_backend_auth(dcb);
|
||||
}
|
||||
|
||||
proto->protocol_auth_state = state;
|
||||
gwbuf_free(readbuf);
|
||||
}
|
||||
else if (proto->protocol_auth_state == MXS_AUTH_STATE_RESPONSE_SENT)
|
||||
{
|
||||
/** Read the message from the server. This will be the first
|
||||
* packet that can contain authenticator specific data from the
|
||||
* backend server. For 'mysql_native_password' it'll be an OK
|
||||
* packet */
|
||||
proto->protocol_auth_state = handle_server_response(dcb, readbuf);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user