~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_all/auth_all.cc

  • Committer: Jay Pipes
  • Date: 2009-09-15 21:01:42 UTC
  • mto: (1126.2.5 merge)
  • mto: This revision was merged to the branch mainline in revision 1128.
  • Revision ID: jpipes@serialcoder-20090915210142-x8mwiqn1q0vzjspp
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
34
 
#include <drizzled/module/option_map.h>
35
 
 
36
 
namespace po= boost::program_options;
37
 
namespace fs= boost::filesystem;
38
 
 
39
 
using namespace std;
40
 
using namespace drizzled;
41
 
 
42
 
namespace auth_all
43
 
{
44
 
 
45
 
static bool opt_allow_anonymous;
46
 
 
47
 
class AuthAll: public plugin::Authentication
48
 
{
49
 
public:
50
 
 
51
 
  AuthAll() :
52
 
    plugin::Authentication("auth_all")
53
 
  {
54
 
  }
55
 
 
56
 
private:
57
 
 
58
 
  /**
59
 
   * Base class method to check authentication for a user.
60
 
   */
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
 
 
73
 
static int init(module::Context &context)
74
 
{
75
 
  context.add(new AuthAll());
76
 
 
77
 
  return 0;
78
 
}
79
 
 
80
 
static 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
 
 
90
 
DRIZZLE_DECLARE_PLUGIN
91
 
{
92
 
  DRIZZLE_VERSION_ID,
93
 
  "Allow-All-Authentication",
94
 
  "1.0",
95
 
  "Brian Aker",
96
 
  "Data Dictionary for utility tables",
97
 
  PLUGIN_LICENSE_GPL,
98
 
  auth_all::init,
99
 
  NULL,
100
 
  auth_all::init_options
101
 
}
102
 
DRIZZLE_DECLARE_PLUGIN_END;