Add authentication plugin name to authenticator API
The authenticators can now declare the authentication plugin name. Right now this is only relevant for MySQL authentication but for example the HTTP module could implement both Basic and Digest authentication.
This commit is contained in:
@ -47,6 +47,7 @@ struct servlistener;
|
|||||||
* authenticate Carry out the authentication
|
* authenticate Carry out the authentication
|
||||||
* free Free extracted data
|
* free Free extracted data
|
||||||
* loadusers Load or update authenticator user data
|
* loadusers Load or update authenticator user data
|
||||||
|
* plugin_name The protocol specific name of the authentication plugin.
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*
|
*
|
||||||
* This forms the "module object" for authenticator modules within the gateway.
|
* This forms the "module object" for authenticator modules within the gateway.
|
||||||
@ -60,6 +61,7 @@ typedef struct gw_authenticator
|
|||||||
int (*authenticate)(struct dcb *);
|
int (*authenticate)(struct dcb *);
|
||||||
void (*free)(struct dcb *);
|
void (*free)(struct dcb *);
|
||||||
int (*loadusers)(struct servlistener *);
|
int (*loadusers)(struct servlistener *);
|
||||||
|
const char* plugin_name;
|
||||||
} GWAUTHENTICATOR;
|
} GWAUTHENTICATOR;
|
||||||
|
|
||||||
/** Return values for the loadusers entry point */
|
/** Return values for the loadusers entry point */
|
||||||
|
@ -71,7 +71,8 @@ static GWAUTHENTICATOR MyObject =
|
|||||||
cdc_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
cdc_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
||||||
cdc_auth_authenticate, /* Authenticate user credentials */
|
cdc_auth_authenticate, /* Authenticate user credentials */
|
||||||
cdc_auth_free_client_data, /* Free the client data held in DCB */
|
cdc_auth_free_client_data, /* Free the client data held in DCB */
|
||||||
cdc_replace_users
|
cdc_replace_users,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cdc_auth_check(
|
static int cdc_auth_check(
|
||||||
|
@ -63,7 +63,8 @@ static GWAUTHENTICATOR MyObject =
|
|||||||
http_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
http_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
||||||
http_auth_authenticate, /* Authenticate user credentials */
|
http_auth_authenticate, /* Authenticate user credentials */
|
||||||
http_auth_free_client_data, /* Free the client data held in DCB */
|
http_auth_free_client_data, /* Free the client data held in DCB */
|
||||||
users_default_loadusers
|
users_default_loadusers,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct http_auth
|
typedef struct http_auth
|
||||||
|
@ -63,7 +63,8 @@ static GWAUTHENTICATOR MyObject =
|
|||||||
max_admin_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
max_admin_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
||||||
max_admin_auth_authenticate, /* Authenticate user credentials */
|
max_admin_auth_authenticate, /* Authenticate user credentials */
|
||||||
max_admin_auth_free_client_data, /* Free the client data held in DCB */
|
max_admin_auth_free_client_data, /* Free the client data held in DCB */
|
||||||
users_default_loadusers
|
users_default_loadusers,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,8 @@ static GWAUTHENTICATOR MyObject =
|
|||||||
mysql_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
mysql_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
||||||
mysql_auth_authenticate, /* Authenticate user credentials */
|
mysql_auth_authenticate, /* Authenticate user credentials */
|
||||||
mysql_auth_free_client_data, /* Free the client data held in DCB */
|
mysql_auth_free_client_data, /* Free the client data held in DCB */
|
||||||
mysql_auth_load_users /* Load users from backend databases */
|
mysql_auth_load_users, /* Load users from backend databases */
|
||||||
|
"mysql_native_password"
|
||||||
};
|
};
|
||||||
|
|
||||||
static int combined_auth_check(
|
static int combined_auth_check(
|
||||||
|
@ -62,7 +62,8 @@ static GWAUTHENTICATOR MyObject =
|
|||||||
null_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
null_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
||||||
null_auth_authenticate, /* Authenticate user credentials */
|
null_auth_authenticate, /* Authenticate user credentials */
|
||||||
null_auth_free_client_data, /* Free the client data held in DCB */
|
null_auth_free_client_data, /* Free the client data held in DCB */
|
||||||
users_default_loadusers
|
users_default_loadusers,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +62,8 @@ static GWAUTHENTICATOR MyObject =
|
|||||||
null_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
null_auth_is_client_ssl_capable, /* Check if client supports SSL */
|
||||||
null_auth_authenticate, /* Authenticate user credentials */
|
null_auth_authenticate, /* Authenticate user credentials */
|
||||||
null_auth_free_client_data, /* Free the client data held in DCB */
|
null_auth_free_client_data, /* Free the client data held in DCB */
|
||||||
users_default_loadusers
|
users_default_loadusers,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,6 +79,8 @@
|
|||||||
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
||||||
#define GW_SCRAMBLE_LENGTH_323 8
|
#define GW_SCRAMBLE_LENGTH_323 8
|
||||||
|
|
||||||
|
#define DEFAULT_AUTH_PLUGIN_NAME "mysql_native_password"
|
||||||
|
|
||||||
/** Maximum length of a MySQL packet */
|
/** Maximum length of a MySQL packet */
|
||||||
#define MYSQL_PACKET_LENGTH_MAX 0x00ffffff
|
#define MYSQL_PACKET_LENGTH_MAX 0x00ffffff
|
||||||
|
|
||||||
|
@ -311,11 +311,15 @@ int MySQLSendHandshake(DCB* dcb)
|
|||||||
|
|
||||||
memcpy(mysql_plugin_data, server_scramble + 8, 12);
|
memcpy(mysql_plugin_data, server_scramble + 8, 12);
|
||||||
|
|
||||||
|
const char* plugin_name = dcb->authfunc.plugin_name ?
|
||||||
|
dcb->authfunc.plugin_name : DEFAULT_AUTH_PLUGIN_NAME;
|
||||||
|
int plugin_name_len = strlen(plugin_name);
|
||||||
|
|
||||||
mysql_payload_size =
|
mysql_payload_size =
|
||||||
sizeof(mysql_protocol_version) + (len_version_string + 1) + sizeof(mysql_thread_id_num) + 8 +
|
sizeof(mysql_protocol_version) + (len_version_string + 1) + sizeof(mysql_thread_id_num) + 8 +
|
||||||
sizeof(/* mysql_filler */ uint8_t) + sizeof(mysql_server_capabilities_one) + sizeof(mysql_server_language) +
|
sizeof(/* mysql_filler */ uint8_t) + sizeof(mysql_server_capabilities_one) + sizeof(mysql_server_language) +
|
||||||
sizeof(mysql_server_status) + sizeof(mysql_server_capabilities_two) + sizeof(mysql_scramble_len) +
|
sizeof(mysql_server_status) + sizeof(mysql_server_capabilities_two) + sizeof(mysql_scramble_len) +
|
||||||
sizeof(mysql_filler_ten) + 12 + sizeof(/* mysql_last_byte */ uint8_t) + strlen("mysql_native_password") +
|
sizeof(mysql_filler_ten) + 12 + sizeof(/* mysql_last_byte */ uint8_t) + plugin_name_len +
|
||||||
sizeof(/* mysql_last_byte */ uint8_t);
|
sizeof(/* mysql_last_byte */ uint8_t);
|
||||||
|
|
||||||
// allocate memory for packet header + payload
|
// allocate memory for packet header + payload
|
||||||
@ -407,8 +411,8 @@ int MySQLSendHandshake(DCB* dcb)
|
|||||||
mysql_handshake_payload++;
|
mysql_handshake_payload++;
|
||||||
|
|
||||||
// to be understanded ????
|
// to be understanded ????
|
||||||
memcpy(mysql_handshake_payload, "mysql_native_password", strlen("mysql_native_password"));
|
memcpy(mysql_handshake_payload, plugin_name, plugin_name_len);
|
||||||
mysql_handshake_payload = mysql_handshake_payload + strlen("mysql_native_password");
|
mysql_handshake_payload = mysql_handshake_payload + plugin_name_len;
|
||||||
|
|
||||||
//write last byte, 0
|
//write last byte, 0
|
||||||
*mysql_handshake_payload = 0x00;
|
*mysql_handshake_payload = 0x00;
|
||||||
|
Reference in New Issue
Block a user