1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Definitions required for Authorization plugin
6
* Copyright (C) 2010 Monty Taylor
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.
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.
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
22
#ifndef DRIZZLED_PLUGIN_AUTHORIZATION_H
23
#define DRIZZLED_PLUGIN_AUTHORIZATION_H
25
#include "drizzled/plugin.h"
26
#include "drizzled/plugin/plugin.h"
27
#include "drizzled/security_context.h"
28
#include "drizzled/identifier.h"
39
class Authorization : public Plugin
42
Authorization(const Authorization &);
43
Authorization& operator=(const Authorization &);
45
explicit Authorization(std::string name_arg)
46
: Plugin(name_arg, "Authorization")
48
virtual ~Authorization() {}
51
* Should we restrict the current user's access to this schema?
53
* @param Current security context
54
* @param Database to check against
56
* @returns true if the user cannot access the schema
58
virtual bool restrictSchema(const SecurityContext &user_ctx,
59
SchemaIdentifier &schema)= 0;
62
* Should we restrict the current user's access to this table?
64
* @param Current security context
65
* @param Database to check against
66
* @param Table to check against
68
* @returns true if the user cannot access the table
70
virtual bool restrictTable(const SecurityContext &user_ctx,
71
TableIdentifier &table);
74
* Should we restrict the current user's access to see this process?
76
* @param Current security context
77
* @param Database to check against
78
* @param Table to check against
80
* @returns true if the user cannot see the process
82
virtual bool restrictProcess(const SecurityContext &user_ctx,
83
const SecurityContext &session_ctx);
85
/** Server API method for checking schema authorization */
86
static bool isAuthorized(const SecurityContext &user_ctx,
87
SchemaIdentifier &schema_identifier,
88
bool send_error= true);
90
/** Server API method for checking table authorization */
91
static bool isAuthorized(const SecurityContext &user_ctx,
92
TableIdentifier &table_identifier,
93
bool send_error= true);
95
/** Server API method for checking process authorization */
96
static bool isAuthorized(const SecurityContext &user_ctx,
97
const Session *session,
98
bool send_error= true);
101
* Server API helper method for applying authorization tests
102
* to a set of schema names (for use in the context of getSchemaNames
104
static void pruneSchemaNames(const SecurityContext &user_ctx,
105
SchemaIdentifiers &set_of_schemas);
108
* Standard plugin system registration hooks
110
static bool addPlugin(plugin::Authorization *auth);
111
static void removePlugin(plugin::Authorization *auth);
115
inline bool Authorization::restrictTable(const SecurityContext &user_ctx,
116
TableIdentifier &table)
118
return restrictSchema(user_ctx, table);
121
inline bool Authorization::restrictProcess(const SecurityContext &,
122
const SecurityContext &)
127
} /* namespace plugin */
129
} /* namespace drizzled */
131
#endif /* DRIZZLED_PLUGIN_AUTHORIZATION_H */