Leosac  0.7.0
OpenSourceAccessControl
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 
21 #include "AuditSerializer.hpp"
22 #include "core/SecurityContext.hpp"
24 #include "tools/log.hpp"
25 
26 namespace Leosac
27 {
28 namespace Audit
29 {
30 namespace Serializer
31 {
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 }
nlohmann::json json
This is the header file for a generated source file, GitSHA1.cpp.
virtual Auth::UserId target_user_id() const =0
Interface to audit object that take care of tracking user/group membership change.
virtual Auth::GroupId target_group_id() const =0
static json serialize(const Audit::IUserGroupMembershipEvent &in, const SecurityContext &sc)
A SecurityContext is used to query permission while doing an operation.
#define ASSERT_LOG(cond, msg)
Definition: log.hpp:221
static json serialize(const Audit::IAuditEntry &in, const SecurityContext &sc)