20#ifndef ORES_IAM_DOMAIN_SESSION_HPP
21#define ORES_IAM_DOMAIN_SESSION_HPP
28#include <boost/uuid/uuid.hpp>
29#include <boost/asio/ip/address.hpp>
30#include "ores.utility/uuid/tenant_id.hpp"
56 default:
return "unknown";
89 boost::uuids::uuid
id;
116 std::optional<std::chrono::system_clock::time_point>
end_time;
175 [[nodiscard]] std::optional<std::chrono::seconds>
duration()
const {
179 return std::chrono::duration_cast<std::chrono::seconds>(
Domain types for identity and access management.
Definition account.hpp:29
constexpr std::string_view to_string(session_protocol p)
Converts a session_protocol to its string representation.
Definition session.hpp:52
session_protocol
Protocol used for the session connection.
Definition session.hpp:37
@ http
HTTP/REST API with JWT authentication.
@ binary
ORE Studio binary protocol over TCP.
constexpr session_protocol session_protocol_from_string(std::string_view s)
Converts a string to session_protocol.
Definition session.hpp:64
Represents a user session in the system.
Definition session.hpp:80
std::optional< std::chrono::seconds > duration() const
Calculates the session duration.
Definition session.hpp:175
std::optional< std::chrono::system_clock::time_point > end_time
Timestamp when the session ended (logout or disconnect).
Definition session.hpp:116
std::string client_identifier
Client identifier string from handshake.
Definition session.hpp:128
std::uint16_t client_version_major
Client protocol version major number.
Definition session.hpp:133
std::uint64_t bytes_sent
Total bytes sent to the client during this session.
Definition session.hpp:143
boost::asio::ip::address client_ip
Client IP address.
Definition session.hpp:121
boost::uuids::uuid account_id
Foreign key referencing the associated account.
Definition session.hpp:94
std::vector< boost::uuids::uuid > visible_party_ids
Visible party IDs for party-level RLS.
Definition session.hpp:104
session_protocol protocol
Protocol used for this session (binary or HTTP).
Definition session.hpp:160
std::uint16_t client_version_minor
Client protocol version minor number.
Definition session.hpp:138
boost::uuids::uuid party_id
Party ID for party-level isolation.
Definition session.hpp:99
std::string username
Username of the account that owns this session.
Definition session.hpp:168
std::uint64_t bytes_received
Total bytes received from the client during this session.
Definition session.hpp:148
boost::uuids::uuid id
Unique identifier for this session.
Definition session.hpp:89
std::chrono::system_clock::time_point start_time
Timestamp when the session started (login time).
Definition session.hpp:109
std::string country_code
ISO 3166-1 alpha-2 country code from geolocation.
Definition session.hpp:155
bool is_active() const
Checks if the session is still active.
Definition session.hpp:186
utility::uuid::tenant_id tenant_id
Tenant identifier for multi-tenancy isolation.
Definition session.hpp:84
Aggregated session statistics for a time period.
Definition session.hpp:194
double avg_bytes_received
Average bytes received per session.
Definition session.hpp:238
double avg_bytes_sent
Average bytes sent per session.
Definition session.hpp:233
std::chrono::system_clock::time_point period_end
End of the time period.
Definition session.hpp:203
boost::uuids::uuid account_id
Account ID if statistics are per-account, nil for aggregate.
Definition session.hpp:208
std::uint32_t unique_countries
Number of unique countries from which sessions originated.
Definition session.hpp:243
std::uint64_t total_bytes_sent
Total bytes sent across all sessions.
Definition session.hpp:223
std::chrono::system_clock::time_point period_start
Start of the time period.
Definition session.hpp:198
std::uint64_t session_count
Total number of sessions in this period.
Definition session.hpp:213
double avg_duration_seconds
Average session duration in seconds.
Definition session.hpp:218
std::uint64_t total_bytes_received
Total bytes received across all sessions.
Definition session.hpp:228
A strongly-typed wrapper around a UUID representing a tenant identifier.
Definition tenant_id.hpp:66
static tenant_id system()
Creates a tenant_id representing the system tenant.
Definition tenant_id.cpp:41