20#ifndef ORES_COMMS_SERVICE_AUTH_SESSION_SERVICE_HPP
21#define ORES_COMMS_SERVICE_AUTH_SESSION_SERVICE_HPP
28#include <boost/uuid/uuid.hpp>
29#include "ores.logging/make_logger.hpp"
30#include "ores.comms/messaging/message_types.hpp"
31#include "ores.comms/service/session_data.hpp"
44 boost::uuids::uuid account_id;
54 std::string client_identifier;
55 std::uint16_t client_version_major = 0;
56 std::uint16_t client_version_minor = 0;
69 inline static std::string_view logger_name =
70 "ores.comms.service.auth_session_service";
74 static auto instance = make_logger(logger_name);
87 [[nodiscard]] std::optional<session_info>
88 get_session(
const std::string& remote_address)
const;
96 [[nodiscard]]
bool is_authenticated(
const std::string& remote_address)
const;
114 std::shared_ptr<session_data> session);
122 [[nodiscard]] std::shared_ptr<session_data>
133 std::uint64_t bytes_sent, std::uint64_t bytes_received);
141 std::shared_ptr<session_data>
154 [[nodiscard]] std::vector<std::shared_ptr<session_data>>
174 [[nodiscard]] std::optional<client_info>
201 [[nodiscard]] std::expected<void, ores::utility::serialization::error_code>
203 const std::string& remote_address)
const;
209 static bool requires_authentication(messaging::message_type type);
211 mutable std::mutex session_mutex_;
212 std::map<std::string, std::shared_ptr<session_data>> sessions_;
214 mutable std::mutex client_info_mutex_;
215 std::map<std::string, client_info> client_infos_;
Main server application for ORE Studio.
Definition application.hpp:30
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Lightweight session info for backward compatibility.
Definition auth_session_service.hpp:43
Client information captured during handshake.
Definition auth_session_service.hpp:53
Centralized authentication session management service.
Definition auth_session_service.hpp:67
void update_session_bytes(const std::string &remote_address, std::uint64_t bytes_sent, std::uint64_t bytes_received)
Update byte counters for an active session.
Definition auth_session_service.cpp:77
std::expected< void, ores::utility::serialization::error_code > authorize_request(messaging::message_type type, const std::string &remote_address) const
Check if a request is authorized based on message type and session.
Definition auth_session_service.cpp:183
bool is_authenticated(const std::string &remote_address) const
Check if a remote address has an authenticated session.
Definition auth_session_service.cpp:52
std::vector< std::shared_ptr< session_data > > clear_all_sessions()
Remove all sessions (e.g., on server shutdown).
Definition auth_session_service.cpp:103
std::optional< client_info > get_client_info(const std::string &remote_address) const
Get client info for a remote address.
Definition auth_session_service.cpp:139
std::shared_ptr< session_data > remove_session(const std::string &remote_address)
Remove session for a remote address.
Definition auth_session_service.cpp:88
std::optional< session_info > get_session(const std::string &remote_address) const
Get session for a remote address.
Definition auth_session_service.cpp:30
std::vector< std::shared_ptr< session_data > > get_all_sessions() const
Get all active sessions.
Definition auth_session_service.cpp:118
std::shared_ptr< session_data > get_session_data(const std::string &remote_address) const
Get full session data for a remote address.
Definition auth_session_service.cpp:43
void remove_client_info(const std::string &remote_address)
Remove client info for a remote address.
Definition auth_session_service.cpp:148
void store_client_info(const std::string &remote_address, client_info info)
Store client info from handshake.
Definition auth_session_service.cpp:128
void store_session(const std::string &remote_address, session_info info)
Store session for a remote address (legacy interface).
Definition auth_session_service.cpp:57
void store_session_data(const std::string &remote_address, std::shared_ptr< session_data > session)
Store full session data for a remote address.
Definition auth_session_service.cpp:68