20#ifndef ORES_COMMS_SERVICE_AUTH_SESSION_SERVICE_HPP
21#define ORES_COMMS_SERVICE_AUTH_SESSION_SERVICE_HPP
27#include <boost/uuid/uuid.hpp>
28#include "ores.utility/log/make_logger.hpp"
29#include "ores.comms/messaging/message_types.hpp"
31namespace ores::comms::service {
37 boost::uuids::uuid account_id;
51 inline static std::string_view logger_name =
52 "ores.comms.service.auth_session_service";
56 static auto instance = make_logger(logger_name);
69 [[nodiscard]] std::optional<session_info>
70 get_session(
const std::string& remote_address)
const;
78 [[nodiscard]]
bool is_authenticated(
const std::string& remote_address)
const;
86 [[nodiscard]]
bool is_admin(
const std::string& remote_address)
const;
122 [[nodiscard]] std::expected<void, messaging::error_code>
124 const std::string& remote_address)
const;
130 static bool requires_authentication(messaging::message_type type);
135 static bool requires_admin(messaging::message_type type);
137 mutable std::mutex session_mutex_;
138 std::map<std::string, session_info> sessions_;
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Information about an authenticated session.
Definition auth_session_service.hpp:36
Centralized authentication session management service.
Definition auth_session_service.hpp:49
bool is_admin(const std::string &remote_address) const
Check if a remote address has an admin session.
Definition auth_session_service.cpp:43
void clear_all_sessions()
Remove all sessions (e.g., on server shutdown).
Definition auth_session_service.cpp:71
bool is_authenticated(const std::string &remote_address) const
Check if a remote address has an authenticated session.
Definition auth_session_service.cpp:38
std::expected< void, messaging::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:120
std::optional< session_info > get_session(const std::string &remote_address) const
Get session for a remote address.
Definition auth_session_service.cpp:29
void remove_session(const std::string &remote_address)
Remove session for a remote address.
Definition auth_session_service.cpp:61
void store_session(const std::string &remote_address, session_info info)
Store session for a remote address.
Definition auth_session_service.cpp:52