ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
auth_session_service Class Referencefinal

Centralized authentication session management service. More...

#include <auth_session_service.hpp>

Collaboration diagram for auth_session_service:
Collaboration graph

Public Member Functions

std::optional< session_infoget_session (const std::string &remote_address) const
 Get session for a remote address.
 
bool is_authenticated (const std::string &remote_address) const
 Check if a remote address has an authenticated session.
 
bool is_admin (const std::string &remote_address) const
 Check if a remote address has an admin session.
 
void store_session (const std::string &remote_address, session_info info)
 Store session for a remote address.
 
void remove_session (const std::string &remote_address)
 Remove session for a remote address.
 
void clear_all_sessions ()
 Remove all sessions (e.g., on server shutdown).
 
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.
 

Detailed Description

Centralized authentication session management service.

Tracks authenticated sessions by remote address. This service is shared across all message handlers to provide consistent authorization checks.

Thread-safety: All public methods are thread-safe.

Member Function Documentation

◆ get_session()

std::optional< session_info > get_session ( const std::string &  remote_address) const

Get session for a remote address.

Parameters
remote_addressThe client's remote address
Returns
Session info if logged in, nullopt otherwise
Here is the caller graph for this function:

◆ is_authenticated()

bool is_authenticated ( const std::string &  remote_address) const

Check if a remote address has an authenticated session.

Parameters
remote_addressThe client's remote address
Returns
true if authenticated, false otherwise

◆ is_admin()

bool is_admin ( const std::string &  remote_address) const

Check if a remote address has an admin session.

Parameters
remote_addressThe client's remote address
Returns
true if authenticated as admin, false otherwise

◆ store_session()

void store_session ( const std::string &  remote_address,
session_info  info 
)

Store session for a remote address.

Parameters
remote_addressThe client's remote address
infoSession information to store

◆ remove_session()

void remove_session ( const std::string &  remote_address)

Remove session for a remote address.

Parameters
remote_addressThe client's remote address

◆ authorize_request()

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.

Centralizes authorization logic for all message types:

  • Some messages don't require authentication (login, bootstrap, heartbeat)
  • Some messages require authentication
  • Some messages require admin privileges
Parameters
typeThe message type being requested
remote_addressThe client's remote address
Returns
Empty expected on success, error_code on failure:
  • authentication_failed if auth required but not logged in
  • authorization_failed if admin required but not admin