Leosac
0.8.0
Open Source Access Control
AccessPointService.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2016 Leosac
3
4
This file is part of Leosac.
5
6
Leosac is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Affero General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Leosac 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
14
GNU Affero General Public License for more details.
15
16
You should have received a copy of the GNU Affero General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include "
LeosacFwd.hpp
"
23
#include "
core/audit/AuditFwd.hpp
"
24
#include "
tools/AssertCast.hpp
"
25
#include "
tools/JSONUtils.hpp
"
26
#include "
tools/log.hpp
"
27
#include "
tools/serializers/ExtensibleSerializer.hpp
"
28
#include <boost/type_index.hpp>
29
#include <map>
30
#include <type_traits>
31
32
namespace
Leosac
33
{
34
namespace
Auth
35
{
36
43
struct
AccessPointBackend
44
{
45
virtual
json
update
(
SecurityContext
&sec_ctx,
Audit::IAuditEntryPtr
,
46
const
json
&req,
IAccessPointPtr
ap) = 0;
47
48
virtual
json
create
(
SecurityContext
&sec_ctx,
Audit::IAuditEntryPtr
,
49
const
json
&req) = 0;
50
51
virtual
json
erase
(
SecurityContext
&sec_ctx,
Audit::IAuditEntryPtr
,
52
const
json
&req,
IAccessPointPtr
ap) = 0;
53
};
54
69
class
AccessPointService
70
:
public
ExtensibleSerializer
<json, Auth::IAccessPoint, const SecurityContext &>
71
{
72
public
:
79
void
register_backend
(
const
std::string &controller_module,
80
AccessPointBackend
*backend)
81
{
82
std::lock_guard<std::mutex> lg(
mutex_
);
83
84
ASSERT_LOG
(
backends_
.count(controller_module) == 0,
85
"A backend for this module is already registered."
);
86
backends_
[controller_module] = backend;
87
}
88
89
void
unregister_backend
(
const
std::string &controller_module)
90
{
91
std::lock_guard<std::mutex> lg(
mutex_
);
92
93
backends_
.erase(controller_module);
94
}
95
101
AccessPointBackend
*
get_backend
(
const
std::string &controller_module);
102
103
private
:
104
mutable
std::mutex
mutex_
;
105
110
std::map<std::string, AccessPointBackend *>
backends_
;
111
};
112
}
113
}
Leosac::Auth::AccessPointService::mutex_
std::mutex mutex_
Definition:
AccessPointService.hpp:104
Leosac::Auth::AccessPointBackend
An AccessPointBackend object is used for module to provide implementation for access point CRUD opera...
Definition:
AccessPointService.hpp:43
Leosac::json
nlohmann::json json
Definition:
AuditSerializer.hpp:29
Leosac::Auth::AccessPointService::unregister_backend
void unregister_backend(const std::string &controller_module)
Definition:
AccessPointService.hpp:89
ASSERT_LOG
#define ASSERT_LOG(cond, msg)
Definition:
log.hpp:190
LeosacFwd.hpp
Leosac::Audit::IAuditEntryPtr
std::shared_ptr< IAuditEntry > IAuditEntryPtr
Definition:
AuditFwd.hpp:40
Leosac::Auth::IAccessPointPtr
std::shared_ptr< IAccessPoint > IAccessPointPtr
Definition:
AuthFwd.hpp:127
Leosac::Auth::AccessPointService::backends_
std::map< std::string, AccessPointBackend * > backends_
The various backend for various type of AccessPoint.
Definition:
AccessPointService.hpp:110
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
Leosac::Auth::AccessPointBackend::update
virtual json update(SecurityContext &sec_ctx, Audit::IAuditEntryPtr, const json &req, IAccessPointPtr ap)=0
Leosac::Auth::AccessPointService
This service lets various AccessPoint backend register and provide implementation to use by the Acces...
Definition:
AccessPointService.hpp:69
JSONUtils.hpp
Leosac::Auth::AccessPointService::get_backend
AccessPointBackend * get_backend(const std::string &controller_module)
Get the AccessPointBackend that supports the given controller_module.
Definition:
AccessPointService.cpp:28
Leosac::Auth::AccessPointService::register_backend
void register_backend(const std::string &controller_module, AccessPointBackend *backend)
Register an AccessPointBackend for controller_module.
Definition:
AccessPointService.hpp:79
Leosac::ExtensibleSerializer
Provides dynamic serializers management for a given object's hierarchy.
Definition:
ExtensibleSerializer.hpp:53
Leosac::Auth::AccessPointBackend::erase
virtual json erase(SecurityContext &sec_ctx, Audit::IAuditEntryPtr, const json &req, IAccessPointPtr ap)=0
log.hpp
Leosac::Auth::AccessPointBackend::create
virtual json create(SecurityContext &sec_ctx, Audit::IAuditEntryPtr, const json &req)=0
AuditFwd.hpp
Leosac::SecurityContext
A SecurityContext is used to query permission while doing an operation.
Definition:
SecurityContext.hpp:40
ExtensibleSerializer.hpp
AssertCast.hpp
src
core
auth
AccessPointService.hpp
Generated on Tue Mar 22 2022 10:48:18 for Leosac by
1.8.17