1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Brian Aker
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include <drizzled/server_includes.h>
22
#include <drizzled/authentication.h>
23
#include <libdrizzle/gettext.h>
25
static bool are_plugins_loaded= false;
27
static bool authenticate_by(THD *thd, plugin_ref plugin, void* p_data)
29
const char *password= (const char *)p_data;
30
authentication_st *auth= plugin_data(plugin, authentication_st *);
34
if (auth && auth->authenticate)
36
if (auth->authenticate(thd, password))
43
bool authenticate_user(THD *thd, const char *password)
45
/* If we never loaded any auth plugins, just return true */
46
if (are_plugins_loaded != true)
49
return plugin_foreach(thd, authenticate_by, DRIZZLE_AUTH_PLUGIN, (void *)password);
53
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));
62
if (plugin->plugin->init)
64
if (plugin->plugin->init(authen))
66
sql_print_error(_("Plugin '%s' init function returned error."),
72
plugin->data= (void *)authen;
73
are_plugins_loaded= true;
81
int authentication_finalizer(st_plugin_int *plugin)
83
authentication_st *authen= (authentication_st *)plugin->data;
86
if (authen && plugin->plugin->deinit)
87
plugin->plugin->deinit(authen);