Leosac
0.8.0
Open Source Access Control
UserGroupMembershipEventSerializer.cpp
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
#include "
UserGroupMembershipEventSerializer.hpp
"
21
#include "
AuditSerializer.hpp
"
22
#include "
core/SecurityContext.hpp
"
23
#include "
core/audit/IUserGroupMembershipEvent.hpp
"
24
#include "
tools/log.hpp
"
25
26
namespace
Leosac
27
{
28
namespace
Audit
29
{
30
namespace
Serializer
31
{
32
json
UserGroupMembershipEventJSON::serialize
(
33
const
Audit::IUserGroupMembershipEvent
&in,
const
SecurityContext
&sc)
34
{
35
auto
serialized =
Audit::Serializer::AuditJSON::serialize
(in, sc);
36
// Now we override the type.
37
ASSERT_LOG
(serialized.at(
"type"
).is_string(),
38
"Base audit serialization did something unexpected."
);
39
serialized[
"type"
] =
"audit-user-group-membership-event"
;
40
41
serialized[
"relationships"
][
"target-user"
] = {
42
{{
"id"
, in.
target_user_id
()}, {
"type"
,
"user"
}}};
43
serialized[
"relationships"
][
"target-group"
] = {
44
{{
"id"
, in.
target_group_id
()}, {
"type"
,
"group"
}}};
45
46
return
serialized;
47
}
48
}
49
}
50
}
Leosac::json
nlohmann::json json
Definition:
AuditSerializer.hpp:29
UserGroupMembershipEventSerializer.hpp
AuditSerializer.hpp
ASSERT_LOG
#define ASSERT_LOG(cond, msg)
Definition:
log.hpp:190
SecurityContext.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
Leosac::Audit::Serializer::AuditJSON::serialize
static json serialize(const Audit::IAuditEntry &in, const SecurityContext &sc)
Definition:
AuditSerializer.cpp:30
Leosac::Audit::IUserGroupMembershipEvent::target_user_id
virtual Auth::UserId target_user_id() const =0
Leosac::Audit::IUserGroupMembershipEvent::target_group_id
virtual Auth::GroupId target_group_id() const =0
IUserGroupMembershipEvent.hpp
Leosac::Audit::Serializer::UserGroupMembershipEventJSON::serialize
static json serialize(const Audit::IUserGroupMembershipEvent &in, const SecurityContext &sc)
Definition:
UserGroupMembershipEventSerializer.cpp:32
log.hpp
Leosac::Audit::IUserGroupMembershipEvent
Interface to audit object that take care of tracking user/group membership change.
Definition:
IUserGroupMembershipEvent.hpp:33
Leosac::SecurityContext
A SecurityContext is used to query permission while doing an operation.
Definition:
SecurityContext.hpp:40
src
core
audit
serializers
UserGroupMembershipEventSerializer.cpp
Generated on Tue Mar 22 2022 10:48:17 for Leosac by
1.8.17