~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authorization.h

Reverted 1103

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
 
 *  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
 
#ifndef DRIZZLED_PLUGIN_AUTHORIZATION_H
23
 
#define DRIZZLED_PLUGIN_AUTHORIZATION_H
24
 
 
25
 
#include "drizzled/plugin.h"
26
 
#include "drizzled/plugin/plugin.h"
27
 
#include "drizzled/identifier.h"
28
 
 
29
 
#include <string>
30
 
#include <set>
31
 
 
32
 
#include "drizzled/visibility.h"
33
 
 
34
 
namespace drizzled
35
 
{
36
 
 
37
 
namespace plugin
38
 
{
39
 
 
40
 
class DRIZZLED_API Authorization : public Plugin
41
 
{
42
 
  Authorization();
43
 
  Authorization(const Authorization &);
44
 
  Authorization& operator=(const Authorization &);
45
 
public:
46
 
  explicit Authorization(std::string name_arg)
47
 
    : Plugin(name_arg, "Authorization")
48
 
  {}
49
 
  virtual ~Authorization() {}
50
 
 
51
 
  /**
52
 
   * Should we restrict the current user's access to this schema?
53
 
   *
54
 
   * @param Current security context
55
 
   * @param Database to check against
56
 
   *
57
 
   * @returns true if the user cannot access the schema
58
 
   */
59
 
  virtual bool restrictSchema(const drizzled::identifier::User &user_ctx,
60
 
                              identifier::Schema::const_reference schema)= 0;
61
 
 
62
 
  /**
63
 
   * Should we restrict the current user's access to this table?
64
 
   *
65
 
   * @param Current security context
66
 
   * @param Database to check against
67
 
   * @param Table to check against
68
 
   *
69
 
   * @returns true if the user cannot access the table
70
 
   */
71
 
  virtual bool restrictTable(const drizzled::identifier::User &user_ctx,
72
 
                             identifier::Table &table);
73
 
 
74
 
  /**
75
 
   * Should we restrict the current user's access to see this process?
76
 
   *
77
 
   * @param Current security context
78
 
   * @param Database to check against
79
 
   * @param Table to check against
80
 
   *
81
 
   * @returns true if the user cannot see the process
82
 
   */
83
 
  virtual bool restrictProcess(const drizzled::identifier::User &user_ctx,
84
 
                               const drizzled::identifier::User &session_ctx);
85
 
 
86
 
  /** Server API method for checking schema authorization */
87
 
  static bool isAuthorized(drizzled::identifier::User::const_shared_ptr user_ctx,
88
 
                           identifier::Schema::const_reference schema_identifier,
89
 
                           bool send_error= true);
90
 
 
91
 
  /** Server API method for checking table authorization */
92
 
  static bool isAuthorized(drizzled::identifier::User::const_shared_ptr user_ctx,
93
 
                           identifier::Table &table_identifier,
94
 
                           bool send_error= true);
95
 
 
96
 
  /** Server API method for checking process authorization */
97
 
  static bool isAuthorized(drizzled::identifier::User::const_shared_ptr user_ctx,
98
 
                           const Session *session,
99
 
                           bool send_error= true);
100
 
 
101
 
  /** Server API method for checking process authorization */
102
 
  static bool isAuthorized(drizzled::identifier::User::const_reference user_ctx,
103
 
                           const Session *session,
104
 
                           bool send_error= true);
105
 
 
106
 
  /**
107
 
   * Server API helper method for applying authorization tests
108
 
   * to a set of schema names (for use in the context of getSchemaNames
109
 
   */
110
 
  static void pruneSchemaNames(drizzled::identifier::User::const_shared_ptr user_ctx,
111
 
                               identifier::Schema::vector &set_of_schemas);
112
 
  
113
 
  /**
114
 
   * Standard plugin system registration hooks
115
 
   */
116
 
  static bool addPlugin(plugin::Authorization *auth);
117
 
  static void removePlugin(plugin::Authorization *auth);
118
 
 
119
 
};
120
 
 
121
 
inline bool Authorization::restrictTable(const drizzled::identifier::User &user_ctx,
122
 
                                         identifier::Table &table)
123
 
{
124
 
  return restrictSchema(user_ctx, table);
125
 
}
126
 
 
127
 
inline bool Authorization::restrictProcess(const drizzled::identifier::User &,
128
 
                                           const drizzled::identifier::User &)
129
 
{
130
 
  return false;
131
 
}
132
 
 
133
 
} /* namespace plugin */
134
 
 
135
 
} /* namespace drizzled */
136
 
 
137
 
#endif /* DRIZZLED_PLUGIN_AUTHORIZATION_H */