00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <fstream>
00024 #include <map>
00025 #include <string>
00026 #include <iostream>
00027
00028 #include <boost/program_options.hpp>
00029
00030 #include <drizzled/configmake.h>
00031 #include <drizzled/plugin/authentication.h>
00032 #include <drizzled/identifier.h>
00033 #include <drizzled/util/convert.h>
00034 #include <drizzled/module/option_map.h>
00035
00036 namespace po= boost::program_options;
00037 namespace fs= boost::filesystem;
00038
00039 using namespace std;
00040 using namespace drizzled;
00041
00042 namespace auth_all
00043 {
00044
00045 static bool opt_allow_anonymous;
00046
00047 class AuthAll: public plugin::Authentication
00048 {
00049 public:
00050
00051 AuthAll() :
00052 plugin::Authentication("auth_all")
00053 {
00054 }
00055
00056 private:
00057
00061 bool authenticate(const identifier::User &sctx, const string &)
00062 {
00063 if (not opt_allow_anonymous)
00064 {
00065 if (sctx.username().empty())
00066 return false;
00067 }
00068
00069 return true;
00070 }
00071 };
00072
00073 static int init(module::Context &context)
00074 {
00075 context.add(new AuthAll());
00076
00077 return 0;
00078 }
00079
00080 static void init_options(drizzled::module::option_context &context)
00081 {
00082 context("allow_anonymous",
00083 po::value<bool>(&opt_allow_anonymous)->default_value(false),
00084 N_("Allow anonymous access"));
00085 }
00086
00087
00088 }
00089
00090 DRIZZLE_DECLARE_PLUGIN
00091 {
00092 DRIZZLE_VERSION_ID,
00093 "Allow-All-Authentication",
00094 "1.0",
00095 "Brian Aker",
00096 "Data Dictionary for utility tables",
00097 PLUGIN_LICENSE_GPL,
00098 auth_all::init,
00099 NULL,
00100 auth_all::init_options
00101 }
00102 DRIZZLE_DECLARE_PLUGIN_END;