drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
auth_all.cc
1/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2011 Brian Aker
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include <config.h>
22
23#include <fstream>
24#include <map>
25#include <string>
26#include <iostream>
27
28#include <boost/program_options.hpp>
29
30#include <drizzled/configmake.h>
31#include <drizzled/plugin/authentication.h>
32#include <drizzled/identifier.h>
33#include <drizzled/util/convert.h>
35
36namespace po= boost::program_options;
37namespace fs= boost::filesystem;
38
39using namespace std;
40using namespace drizzled;
41
42namespace auth_all
43{
44
45static bool opt_allow_anonymous;
46
47class AuthAll: public plugin::Authentication
48{
49public:
50
51 AuthAll() :
52 plugin::Authentication("auth_all")
53 {
54 }
55
56private:
57
61 bool authenticate(const identifier::User &sctx, const string &)
62 {
63 if (not opt_allow_anonymous)
64 {
65 if (sctx.username().empty())
66 return false;
67 }
68
69 return true;
70 }
71};
72
73static int init(module::Context &context)
74{
75 context.add(new AuthAll());
76
77 return 0;
78}
79
80static void init_options(drizzled::module::option_context &context)
81{
82 context("allow-anonymous",
83 po::value<bool>(&opt_allow_anonymous)->default_value(false),
84 N_("Allow anonymous access"));
85}
86
87
88} /* namespace auth_all */
89
90DRIZZLE_DECLARE_PLUGIN
91{
92 DRIZZLE_VERSION_ID,
93 "auth_all",
94 "1.0",
95 "Brian Aker",
96 N_("Allows all users to authenticate regardless of username or password"),
97 PLUGIN_LICENSE_GPL,
98 auth_all::init,
99 NULL,
100 auth_all::init_options
101}
102DRIZZLE_DECLARE_PLUGIN_END;
bool authenticate(const identifier::User &sctx, const string &)
Definition auth_all.cc:61
A set of Session members describing the current authenticated user.
TODO: Rename this file - func.h is stupid.
STL namespace.
An Proxy Wrapper around boost::program_options::variables_map.