Drizzled Public API Documentation

authorization.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Definitions required for Authorization plugin
5  *
6  * Copyright (C) 2010 Monty Taylor
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #pragma once
23 
24 #include <drizzled/plugin.h>
25 #include <drizzled/plugin/plugin.h>
26 #include <drizzled/identifier.h>
27 
28 #include <string>
29 #include <set>
30 
31 #include <drizzled/visibility.h>
32 
33 namespace drizzled
34 {
35 
36 namespace plugin
37 {
38 
40 {
41 public:
42  explicit Authorization(std::string name_arg)
43  : Plugin(name_arg, "Authorization")
44  {}
45 
54  virtual bool restrictSchema(const drizzled::identifier::User &user_ctx,
55  const identifier::Schema& schema)= 0;
56 
66  virtual bool restrictTable(const drizzled::identifier::User& user_ctx,
67  const drizzled::identifier::Table& table);
68 
78  virtual bool restrictProcess(const drizzled::identifier::User &user_ctx,
79  const drizzled::identifier::User &session_ctx);
80 
82  static bool isAuthorized(const drizzled::identifier::User& user_ctx,
83  const identifier::Schema& schema_identifier,
84  bool send_error= true);
85 
87  static bool isAuthorized(const drizzled::identifier::User& user_ctx,
88  const drizzled::identifier::Table& table_identifier,
89  bool send_error= true);
90 
92  static bool isAuthorized(const drizzled::identifier::User& user_ctx,
93  const Session &session,
94  bool send_error= true);
95 
100  static void pruneSchemaNames(const drizzled::identifier::User& user_ctx,
101  identifier::schema::vector &set_of_schemas);
102 
106  static bool addPlugin(plugin::Authorization *auth);
107  static void removePlugin(plugin::Authorization *auth);
108 
109 };
110 
112  const drizzled::identifier::Table& table)
113 {
114  return restrictSchema(user_ctx, table);
115 }
116 
119 {
120  return false;
121 }
122 
123 } /* namespace plugin */
124 
125 } /* namespace drizzled */
126