Drizzled Public API Documentation

authorization.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Definitions required for Authorization plugin
00005  *
00006  *  Copyright (C) 2010 Monty Taylor
00007  *
00008  *  This program is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; version 2 of the License.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #pragma once
00023 
00024 #include <drizzled/plugin.h>
00025 #include <drizzled/plugin/plugin.h>
00026 #include <drizzled/identifier.h>
00027 
00028 #include <string>
00029 #include <set>
00030 
00031 #include <drizzled/visibility.h>
00032 
00033 namespace drizzled
00034 {
00035 
00036 namespace plugin
00037 {
00038 
00039 class DRIZZLED_API Authorization : public Plugin
00040 {
00041 public:
00042   explicit Authorization(std::string name_arg)
00043     : Plugin(name_arg, "Authorization")
00044   {}
00045 
00054   virtual bool restrictSchema(const drizzled::identifier::User &user_ctx,
00055                               const identifier::Schema& schema)= 0;
00056 
00066   virtual bool restrictTable(const drizzled::identifier::User& user_ctx,
00067                              const drizzled::identifier::Table& table);
00068 
00078   virtual bool restrictProcess(const drizzled::identifier::User &user_ctx,
00079                                const drizzled::identifier::User &session_ctx);
00080 
00082   static bool isAuthorized(const drizzled::identifier::User& user_ctx,
00083                            const identifier::Schema& schema_identifier,
00084                            bool send_error= true);
00085 
00087   static bool isAuthorized(const drizzled::identifier::User& user_ctx,
00088                            const drizzled::identifier::Table& table_identifier,
00089                            bool send_error= true);
00090 
00092   static bool isAuthorized(const drizzled::identifier::User& user_ctx,
00093                            const Session &session,
00094                            bool send_error= true);
00095 
00100   static void pruneSchemaNames(const drizzled::identifier::User& user_ctx,
00101                                identifier::schema::vector &set_of_schemas);
00102   
00106   static bool addPlugin(plugin::Authorization *auth);
00107   static void removePlugin(plugin::Authorization *auth);
00108 
00109 };
00110 
00111 inline bool Authorization::restrictTable(const drizzled::identifier::User& user_ctx,
00112                                          const drizzled::identifier::Table& table)
00113 {
00114   return restrictSchema(user_ctx, table);
00115 }
00116 
00117 inline bool Authorization::restrictProcess(const drizzled::identifier::User &,
00118                                            const drizzled::identifier::User &)
00119 {
00120   return false;
00121 }
00122 
00123 } /* namespace plugin */
00124 
00125 } /* namespace drizzled */
00126