21
21
#include <drizzled/server_includes.h>
22
22
#include <drizzled/authentication.h>
23
#include <libdrizzle/gettext.h>
23
#include <drizzled/gettext.h>
24
#include <drizzled/errmsg_print.h>
25
26
static bool are_plugins_loaded= false;
27
static bool authenticate_by(THD *thd, plugin_ref plugin, void* p_data)
28
static bool authenticate_by(Session *session, plugin_ref plugin, void* p_data)
29
30
const char *password= (const char *)p_data;
30
authentication_st *auth= plugin_data(plugin, authentication_st *);
31
Authentication *auth= plugin_data(plugin, Authentication *);
34
if (auth && auth->authenticate)
36
if (auth->authenticate(thd, password))
37
if (auth->authenticate(session, password))
43
bool authenticate_user(THD *thd, const char *password)
44
bool authenticate_user(Session *session, const char *password)
45
46
/* If we never loaded any auth plugins, just return true */
46
47
if (are_plugins_loaded != true)
49
return plugin_foreach(thd, authenticate_by, DRIZZLE_AUTH_PLUGIN, (void *)password);
50
return plugin_foreach(session, authenticate_by, DRIZZLE_AUTH_PLUGIN, (void *)password);
53
54
int authentication_initializer(st_plugin_int *plugin)
55
authentication_st *authen;
57
if ((authen= (authentication_st *)malloc(sizeof(authentication_st))) == 0)
60
memset(authen, 0, sizeof(authentication_st));
56
Authentication *authen;
62
59
if (plugin->plugin->init)
64
if (plugin->plugin->init(authen))
61
if (plugin->plugin->init(&authen))
66
sql_print_error(_("Plugin '%s' init function returned error."),
63
errmsg_printf(ERRMSG_LVL_ERROR,
64
_("Plugin '%s' init function returned error."),
72
plugin->data= (void *)authen;
73
plugin->data= static_cast<void *>(authen);
73
74
are_plugins_loaded= true;
81
82
int authentication_finalizer(st_plugin_int *plugin)
83
authentication_st *authen= (authentication_st *)plugin->data;
84
Authentication *authen= static_cast<Authentication *>(plugin->data);
86
87
if (authen && plugin->plugin->deinit)
87
88
plugin->plugin->deinit(authen);