Update copyright dates
[src/app-framework-binder.git] / include / afb / afb-auth.h
1 /*
2  * Copyright (C) 2015-2020 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 /** @defgroup AFB_AUTH
21  *  @{ */
22
23
24 /**
25  * Enumeration  for authority (Session/Token/Assurance) definitions.
26  *
27  * @see afb_auth
28  */
29 enum afb_auth_type
30 {
31         /** never authorized, no data */
32         afb_auth_No = 0,
33
34         /** authorized if token valid, no data */
35         afb_auth_Token,
36
37         /** authorized if LOA greater than or equal to data 'loa' */
38         afb_auth_LOA,
39
40         /** authorized if permission 'text' is granted */
41         afb_auth_Permission,
42
43         /** authorized if 'first' or 'next' is authorized */
44         afb_auth_Or,
45
46         /** authorized if 'first' and 'next' are authorized */
47         afb_auth_And,
48
49         /** authorized if 'first' is not authorized */
50         afb_auth_Not,
51
52         /** always authorized, no data */
53         afb_auth_Yes
54 };
55
56 /**
57  * Definition of an authorization entry
58  */
59 struct afb_auth
60 {
61         /** type of entry @see afb_auth_type */
62         enum afb_auth_type type;
63
64         union {
65                 /** text when @ref type == @ref afb_auth_Permission */
66                 const char *text;
67
68                 /** level of assurancy when @ref type ==  @ref afb_auth_LOA */
69                 unsigned loa;
70
71                 /** first child when @ref type in { @ref afb_auth_Or, @ref afb_auth_And, @ref afb_auth_Not } */
72                 const struct afb_auth *first;
73         };
74
75         /** second child when @ref type in { @ref afb_auth_Or, @ref afb_auth_And } */
76         const struct afb_auth *next;
77 };
78
79 /** @} */