00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 }
00124
00125 }
00126