xref: /qemu/include/authz/simple.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
1 /*
2  * QEMU simple authorization driver
3  *
4  * Copyright (c) 2018 Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef QAUTHZ_SIMPLE_H
22 #define QAUTHZ_SIMPLE_H
23 
24 #include "authz/base.h"
25 #include "qom/object.h"
26 
27 #define TYPE_QAUTHZ_SIMPLE "authz-simple"
28 
29 typedef struct QAuthZSimple QAuthZSimple;
30 typedef struct QAuthZSimpleClass QAuthZSimpleClass;
31 #define QAUTHZ_SIMPLE_CLASS(klass)                        \
32     OBJECT_CLASS_CHECK(QAuthZSimpleClass, (klass),        \
33                        TYPE_QAUTHZ_SIMPLE)
34 #define QAUTHZ_SIMPLE_GET_CLASS(obj)              \
35     OBJECT_GET_CLASS(QAuthZSimpleClass, (obj),    \
36                       TYPE_QAUTHZ_SIMPLE)
37 #define QAUTHZ_SIMPLE(obj) \
38     OBJECT_CHECK(QAuthZSimple, (obj), \
39                  TYPE_QAUTHZ_SIMPLE)
40 
41 
42 
43 /**
44  * QAuthZSimple:
45  *
46  * This authorization driver provides a simple mechanism
47  * for granting access based on an exact matched username.
48  *
49  * To create an instance of this class via QMP:
50  *
51  *  {
52  *    "execute": "object-add",
53  *    "arguments": {
54  *      "qom-type": "authz-simple",
55  *      "id": "authz0",
56  *      "props": {
57  *        "identity": "fred"
58  *      }
59  *    }
60  *  }
61  *
62  * Or via the command line
63  *
64  *   -object authz-simple,id=authz0,identity=fred
65  *
66  */
67 struct QAuthZSimple {
68     QAuthZ parent_obj;
69 
70     char *identity;
71 };
72 
73 
74 struct QAuthZSimpleClass {
75     QAuthZClass parent_class;
76 };
77 
78 
79 QAuthZSimple *qauthz_simple_new(const char *id,
80                                 const char *identity,
81                                 Error **errp);
82 
83 
84 #endif /* QAUTHZ_SIMPLE_H */
85