Leosac  0.8.0
Open Source Access Control
WSAPICall.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 "AuditEntry.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
33 class WSAPICall : virtual public IWSAPICall, public AuditEntry
34 {
35  private:
36  WSAPICall();
37 
38  friend class Factory;
39 
40  static WSAPICallPtr create(const DBPtr &database);
41 
42  public:
43  virtual ~WSAPICall() = default;
44 
45  virtual void method(const std::string &string) override;
46 
47  virtual void uuid(const std::string &string) override;
48 
49  virtual void status_code(APIStatusCode code) override;
50 
51  virtual void status_string(const std::string &string) override;
52 
53  virtual void source_endpoint(const std::string &string) override;
54 
55  virtual void request_content(const std::string &string) override;
56 
57  virtual void response_content(const std::string &string) override;
58 
59  virtual void database_operations(uint16_t nb_operation) override;
60 
61  virtual const std::string &method() const override;
62 
63  virtual const std::string &uuid() const override;
64 
65  virtual APIStatusCode status_code() const override;
66 
67  virtual const std::string &status_string() const override;
68 
69  virtual const std::string &source_endpoint() const override;
70 
71  virtual std::string generate_description() const override;
72 
73 #pragma db not_null
74  std::string api_method_;
75 
79 #pragma db not_null
80  std::string uuid_;
81 
85 #pragma db not_null
87 
91 #pragma db not_null
92  std::string status_string_;
93 
98 #pragma db not_null
99  std::string source_endpoint_;
100 
104  std::string request_content_;
105 
109  std::string response_content_;
110 
116 
117  private:
118  friend class odb::access;
119 };
120 }
121 }
122 
123 #ifdef ODB_COMPILER
124 #include "core/auth/User.hpp"
125 #endif
Leosac::Audit::WSAPICall::source_endpoint
virtual const std::string & source_endpoint() const override
Definition: WSAPICall.cpp:115
Leosac::Audit::WSAPICall::database_operations_
uint16_t database_operations_
Count the number of database operation that happened while processing this API call.
Definition: WSAPICall.hpp:115
Leosac::Audit::WSAPICall::request_content_
std::string request_content_
Copy of the JSON content of the request.
Definition: WSAPICall.hpp:104
AuditEntry.hpp
Leosac::Audit::WSAPICall::WSAPICall
WSAPICall()
Definition: WSAPICall.cpp:29
Leosac::Audit::WSAPICall::create
static WSAPICallPtr create(const DBPtr &database)
Definition: WSAPICall.cpp:35
Leosac::Audit::WSAPICall::source_endpoint_
std::string source_endpoint_
The source IP:Port of the client who made the request.
Definition: WSAPICall.hpp:99
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
User.hpp
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac::Audit::WSAPICall::status_string_
std::string status_string_
The status string of the response.
Definition: WSAPICall.hpp:92
Leosac::Audit::WSAPICall::status_code_
APIStatusCode status_code_
Status code of the response.
Definition: WSAPICall.hpp:86
Leosac::Audit::WSAPICall::method
virtual const std::string & method() const override
Definition: WSAPICall.cpp:95
Leosac::Audit::WSAPICall::database_operations
virtual void database_operations(uint16_t nb_operation) override
The number of database queries.
Definition: WSAPICall.cpp:89
Leosac::Audit::WSAPICall::generate_description
virtual std::string generate_description() const override
Generate a description for this event.
Definition: WSAPICall.cpp:120
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Audit::WSAPICall::response_content
virtual void response_content(const std::string &string) override
Definition: WSAPICall.cpp:83
Leosac::Audit::WSAPICall::status_string
virtual const std::string & status_string() const override
Definition: WSAPICall.cpp:110
Leosac::Audit::WSAPICall::access
friend class odb::access
Definition: WSAPICall.hpp:118
Leosac::Audit::WSAPICall::uuid_
std::string uuid_
The UUID of the request.
Definition: WSAPICall.hpp:80
Leosac::Audit::WSAPICall::uuid
virtual const std::string & uuid() const override
Definition: WSAPICall.cpp:100
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Audit::WSAPICall::request_content
virtual void request_content(const std::string &string) override
The (JSON) content of the request.
Definition: WSAPICall.cpp:77
Leosac::Audit::WSAPICall::api_method_
std::string api_method_
Definition: WSAPICall.hpp:74
Leosac::APIStatusCode
APIStatusCode
Those are the Leosac API status code.
Definition: APIStatusCode.hpp:31
IWSAPICall.hpp
Leosac::Audit::WSAPICall::~WSAPICall
virtual ~WSAPICall()=default
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
Leosac::Audit::WSAPICallPtr
std::shared_ptr< WSAPICall > WSAPICallPtr
Definition: AuditFwd.hpp:90
Leosac::Audit::WSAPICall::status_code
virtual APIStatusCode status_code() const override
Definition: WSAPICall.cpp:105
Leosac::Audit::WSAPICall::response_content_
std::string response_content_
Copy of the JSON content of the response.
Definition: WSAPICall.hpp:109
Leosac::Audit::WSAPICall
Provides the implementation of IWSAPICall.
Definition: WSAPICall.hpp:33
Leosac::Audit::IWSAPICall
An audit entry dedicated to tracing API call.
Definition: IWSAPICall.hpp:39