21
21
#include "drizzled/server_includes.h"
22
#include "drizzled/authentication.h"
23
#include "drizzled/gettext.h"
22
#include "drizzled/plugin/authentication.h"
24
23
#include "drizzled/errmsg_print.h"
25
24
#include "drizzled/plugin/registry.h"
25
#include "drizzled/gettext.h"
29
29
using namespace std;
31
static vector<Authentication *> all_authentication;
33
static bool are_plugins_loaded= false;
35
void add_authentication(Authentication *auth)
37
all_authentication.push_back(auth);
40
void remove_authentication(Authentication *auth)
42
all_authentication.erase(find(all_authentication.begin(),
43
all_authentication.end(),
47
class AuthenticateBy : public unary_function<Authentication *, bool>
34
std::vector<plugin::Authentication *> all_authentication;
35
bool are_plugins_loaded= false;
38
bool plugin::Authentication::addPlugin(plugin::Authentication *auth)
41
all_authentication.push_back(auth);
45
void plugin::Authentication::removePlugin(plugin::Authentication *auth)
48
all_authentication.erase(find(all_authentication.begin(),
49
all_authentication.end(),
53
class AuthenticateBy : public unary_function<plugin::Authentication *, bool>
50
56
const char *password;
52
58
AuthenticateBy(Session *session_arg, const char *password_arg) :
53
unary_function<Authentication *, bool>(),
59
unary_function<plugin::Authentication *, bool>(),
54
60
session(session_arg), password(password_arg) {}
56
62
inline result_type operator()(argument_type auth)
62
bool authenticate_user(Session *session, const char *password)
68
bool plugin::Authentication::isAuthenticated(Session *session,
64
71
/* If we never loaded any auth plugins, just return true */
65
72
if (are_plugins_loaded != true)
68
75
/* Use find_if instead of foreach so that we can collect return codes */
69
vector<Authentication *>::iterator iter=
76
vector<plugin::Authentication *>::iterator iter=
70
77
find_if(all_authentication.begin(), all_authentication.end(),
71
78
AuthenticateBy(session, password));
72
79
/* If iter is == end() here, that means that all of the plugins returned