~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/simple_user_policy/module.cc

  • Committer: Andrew Hutchings
  • Date: 2010-11-01 22:14:18 UTC
  • mto: This revision was merged to the branch mainline in revision 1907.
  • Revision ID: andrew@linuxjedi.co.uk-20101101221418-9n9gmm4ms7fl8vo5
Fix copyright

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include "config.h"
21
21
 
22
 
#include <string>
23
 
 
24
 
#include "drizzled/plugin/authorization.h"
25
 
#include "drizzled/security_context.h"
26
 
 
 
22
#include <drizzled/plugin/authorization.h>
 
23
 
 
24
#include "policy.h"
27
25
 
28
26
using namespace drizzled;
29
27
 
30
 
namespace authz
31
 
{
32
 
 
33
 
class Authz :
34
 
  public plugin::Authorization
35
 
{
36
 
public:
37
 
  Authz() :
38
 
    plugin::Authorization("test authz")
39
 
  { }
40
 
 
41
 
  /* I told you it was a silly plugin.
42
 
    If the db name is authz_no and the user is authz, then it's blocked
43
 
    If it's anything else, it's approved
44
 
  */
45
 
  virtual bool restrictSchema(const SecurityContext &user_ctx,
46
 
                              const std::string &db)
47
 
  {
48
 
    if (db == "authz_no" and user_ctx.getUser() == "authz")
49
 
      return true;
50
 
    return false;
51
 
  }
52
 
 
53
 
  virtual bool restrictProcess(const SecurityContext &user_ctx,
54
 
                               const SecurityContext &session_ctx)
55
 
  {
56
 
    if (user_ctx.getUser() == session_ctx.getUser())
57
 
      return false;
58
 
    if (user_ctx.getUser() == "authz")
59
 
      return true;
60
 
    return false;
61
 
  }
62
 
};
63
 
 
64
 
Authz *authz= NULL;
65
 
 
66
 
static int init(plugin::Context &context)
67
 
{
68
 
  authz= new Authz();
69
 
  context.add(authz);
 
28
namespace simple_user_policy
 
29
{
 
30
 
 
31
static int init(module::Context &context)
 
32
{
 
33
  context.add(new Policy);
70
34
  return 0;
71
35
}
72
36
 
73
 
} /* namespace authz */
 
37
} /* namespace simple_user_policy */
74
38
 
75
 
DRIZZLE_PLUGIN(authz::init, NULL);
 
39
DRIZZLE_PLUGIN(simple_user_policy::init, NULL, NULL);