1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Monty Taylor <mordred@inaugust.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef PLUGIN_SIMPLE_USER_POLICY_POLICY_H
22
#define PLUGIN_SIMPLE_USER_POLICY_POLICY_H
26
#include <drizzled/plugin/authorization.h>
28
namespace simple_user_policy
32
public drizzled::plugin::Authorization
36
drizzled::plugin::Authorization("Simple User Policy")
39
virtual bool restrictSchema(const drizzled::SecurityContext &user_ctx,
40
drizzled::SchemaIdentifier &db);
42
virtual bool restrictProcess(const drizzled::SecurityContext &user_ctx,
43
const drizzled::SecurityContext &session_ctx);
46
inline bool Policy::restrictSchema(const drizzled::SecurityContext &user_ctx,
47
drizzled::SchemaIdentifier &schema)
49
if ((user_ctx.getUser() == "root")
50
|| schema.compare("data_dictionary")
51
|| schema.compare("information_schema"))
53
return not schema.compare(user_ctx.getUser());
56
inline bool Policy::restrictProcess(const drizzled::SecurityContext &user_ctx,
57
const drizzled::SecurityContext &session_ctx)
59
if (user_ctx.getUser() == "root")
61
return user_ctx.getUser() != session_ctx.getUser();
64
} /* namespace simple_user_policy */
66
#endif /* PLUGIN_SIMPLE_USER_POLICY_POLICY_H */