21
21
#include "drizzled/server_includes.h"
22
#include "drizzled/authentication.h"
23
#include "drizzled/gettext.h"
22
#include "drizzled/slot/authentication.h"
24
23
#include "drizzled/errmsg_print.h"
25
24
#include "drizzled/plugin/registry.h"
25
#include "drizzled/plugin/authentication.h"
26
#include "drizzled/gettext.h"
30
using namespace drizzled;
29
31
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
void slot::Authentication::add(plugin::Authentication *auth)
37
all_authentication.push_back(auth);
40
void slot::Authentication::remove(plugin::Authentication *auth)
43
all_authentication.erase(find(all_authentication.begin(),
44
all_authentication.end(),
55
class AuthenticateBy : public unary_function<plugin::Authentication *, bool>
50
58
const char *password;
52
60
AuthenticateBy(Session *session_arg, const char *password_arg) :
53
unary_function<Authentication *, bool>(),
61
unary_function<plugin::Authentication *, bool>(),
54
62
session(session_arg), password(password_arg) {}
56
64
inline result_type operator()(argument_type auth)
58
66
return auth->authenticate(session, password);
69
} /* namespace auth_priv */
70
} /* namespace slot */
71
} /* namespace drizzled */
62
bool authenticate_user(Session *session, const char *password)
73
bool slot::Authentication::authenticate(Session *session, const char *password)
64
75
/* If we never loaded any auth plugins, just return true */
65
76
if (are_plugins_loaded != true)
68
79
/* Use find_if instead of foreach so that we can collect return codes */
69
vector<Authentication *>::iterator iter=
80
vector<plugin::Authentication *>::iterator iter=
70
81
find_if(all_authentication.begin(), all_authentication.end(),
71
AuthenticateBy(session, password));
82
slot::auth_priv::AuthenticateBy(session, password));
72
83
/* If iter is == end() here, that means that all of the plugins returned
73
84
* false, which in this case means they all succeeded. Since we want to
74
85
* return false on success, we return the value of the two being !=