ORE Studio 0.0.4
Loading...
Searching...
No Matches
auth_event_repository.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_IAM_REPOSITORY_AUTH_EVENT_REPOSITORY_HPP
21#define ORES_IAM_REPOSITORY_AUTH_EVENT_REPOSITORY_HPP
22
23#include <chrono>
24#include <string>
25#include <sqlgen/postgres.hpp>
26#include "ores.logging/make_logger.hpp"
27#include "ores.database/domain/context.hpp"
28
29namespace ores::iam::repository {
30
41private:
42 inline static std::string_view logger_name =
43 "ores.iam.repository.auth_event_repository";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::logging;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
53 explicit auth_event_repository(context ctx);
54
66 const std::chrono::system_clock::time_point& event_time,
67 const std::string& tenant_id,
68 const std::string& account_id,
69 const std::string& username,
70 const std::string& session_id,
71 const std::string& party_id);
72
82 const std::chrono::system_clock::time_point& event_time,
83 const std::string& tenant_id,
84 const std::string& username,
85 const std::string& error_detail);
86
96 void record_logout(
97 const std::chrono::system_clock::time_point& event_time,
98 const std::string& tenant_id,
99 const std::string& account_id,
100 const std::string& username,
101 const std::string& session_id);
102
113 const std::chrono::system_clock::time_point& event_time,
114 const std::string& tenant_id,
115 const std::string& account_id,
116 const std::string& username,
117 const std::string& session_id);
118
132 const std::chrono::system_clock::time_point& event_time,
133 const std::string& tenant_id,
134 const std::string& account_id,
135 const std::string& username,
136 const std::string& session_id);
137
147 const std::chrono::system_clock::time_point& event_time,
148 const std::string& tenant_id,
149 const std::string& account_id,
150 const std::string& username);
151
161 const std::chrono::system_clock::time_point& event_time,
162 const std::string& tenant_id,
163 const std::string& username,
164 const std::string& error_detail);
165
166private:
167 void insert(const std::string& event_type,
168 const std::chrono::system_clock::time_point& event_time,
169 const std::string& tenant_id,
170 const std::string& account_id,
171 const std::string& username,
172 const std::string& session_id,
173 const std::string& party_id,
174 const std::string& error_detail);
175
176 context ctx_;
177};
178
179}
180
181#endif
Database persistence layer for IAM domain types.
Definition account_entity.hpp:28
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Repository for inserting JWT authentication telemetry events.
Definition auth_event_repository.hpp:40
void record_token_refresh(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &account_id, const std::string &username, const std::string &session_id)
Record a successful token refresh event.
Definition auth_event_repository.cpp:101
void record_signup_failure(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &username, const std::string &error_detail)
Record a signup failure event.
Definition auth_event_repository.cpp:130
void record_login_failure(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &username, const std::string &error_detail)
Record a login failure event.
Definition auth_event_repository.cpp:82
void record_login_success(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &account_id, const std::string &username, const std::string &session_id, const std::string &party_id)
Record a login success event.
Definition auth_event_repository.cpp:71
void record_max_session_exceeded(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &account_id, const std::string &username, const std::string &session_id)
Record a max_session_exceeded event.
Definition auth_event_repository.cpp:111
void record_logout(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &account_id, const std::string &username, const std::string &session_id)
Record a logout event.
Definition auth_event_repository.cpp:91
void record_signup_success(const std::chrono::system_clock::time_point &event_time, const std::string &tenant_id, const std::string &account_id, const std::string &username)
Record a signup success event.
Definition auth_event_repository.cpp:121