ORE Studio 0.0.4
Loading...
Searching...
No Matches
service_session_service.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_SERVICE_SERVICE_SESSION_SERVICE_HPP
21#define ORES_IAM_SERVICE_SERVICE_SESSION_SERVICE_HPP
22
23#include <string>
24#include <optional>
25#include <boost/uuid/uuid.hpp>
26#include "ores.iam.api/domain/session.hpp"
27#include "ores.iam.core/repository/session_repository.hpp"
28#include "ores.iam.core/repository/account_repository.hpp"
29#include "ores.utility/uuid/uuid_v7_generator.hpp"
30#include "ores.logging/make_logger.hpp"
31
32namespace ores::iam::service {
33
42private:
43 inline static std::string_view logger_name =
44 "ores.iam.service.service_session_service";
45
46 [[nodiscard]] static auto& lg() {
47 using namespace ores::logging;
48 static auto instance = make_logger(logger_name);
49 return instance;
50 }
51
52public:
54
60 explicit service_session_service(context ctx);
61
75 std::optional<domain::session> start_service_session(
76 const std::string& username,
77 const std::string& client_identifier,
79
89 std::optional<domain::session> start_service_session(
90 const boost::uuids::uuid& account_id,
91 const std::string& client_identifier,
93
105 const boost::uuids::uuid& session_id,
106 const std::chrono::system_clock::time_point& start_time,
107 std::uint64_t bytes_sent = 0,
108 std::uint64_t bytes_received = 0);
109
116 std::optional<domain::account> get_service_account(const std::string& username);
117
118private:
119 repository::session_repository session_repo_;
120 repository::account_repository account_repo_;
121 utility::uuid::uuid_v7_generator uuid_generator_;
122};
123
124}
125
126#endif
session_protocol
Protocol used for the session connection.
Definition session.hpp:37
@ binary
ORE Studio binary protocol over TCP.
Service layer for the IAM module.
Definition auth_session_service.hpp:32
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Reads and writes accounts off of data storage.
Definition account_repository.hpp:37
Repository for session persistence and querying.
Definition session_repository.hpp:40
Service for managing service account sessions.
Definition service_session_service.hpp:41
std::optional< domain::session > start_service_session(const std::string &username, const std::string &client_identifier, domain::session_protocol protocol=domain::session_protocol::binary)
Starts a session for a service account.
Definition service_session_service.cpp:59
void end_service_session(const boost::uuids::uuid &session_id, const std::chrono::system_clock::time_point &start_time, std::uint64_t bytes_sent=0, std::uint64_t bytes_received=0)
Ends a service session.
Definition service_session_service.cpp:131
std::optional< domain::account > get_service_account(const std::string &username)
Looks up a service account by username.
Definition service_session_service.cpp:37
A generator for UUID version 7 (v7) based on RFC 9562.
Definition uuid_v7_generator.hpp:50