ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
bootstrap_mode_service Class Reference

Service for managing system bootstrap mode state. More...

#include <bootstrap_mode_service.hpp>

Collaboration diagram for bootstrap_mode_service:
Collaboration graph

Public Types

using context = ores::database::context
 

Public Member Functions

 bootstrap_mode_service (database::context ctx, std::string tenant_id, std::shared_ptr< authorization_service > auth_service)
 Constructs a bootstrap_mode_service with required repositories.
 
bool is_in_bootstrap_mode ()
 Checks if the system is currently in bootstrap mode.
 
void initialize_bootstrap_state ()
 Initializes the bootstrap mode state on system startup.
 
void exit_bootstrap_mode ()
 Transitions the system from bootstrap mode to secure mode.
 

Detailed Description

Service for managing system bootstrap mode state.

The bootstrap_mode_service manages the system's bootstrap mode, which is a special state where only the initial administrator account can be created. The service uses the system_settings table to persist the bootstrap mode state with the setting name "system.bootstrap_mode".

Bootstrap mode logic:

The service provides methods to:

Constructor & Destructor Documentation

◆ bootstrap_mode_service()

bootstrap_mode_service ( database::context  ctx,
std::string  tenant_id,
std::shared_ptr< authorization_service auth_service 
)

Constructs a bootstrap_mode_service with required repositories.

Parameters
ctxThe database context for repository access
tenant_idThe tenant identifier for multi-tenancy isolation
auth_serviceThe authorization service for RBAC checks

Member Function Documentation

◆ is_in_bootstrap_mode()

bool is_in_bootstrap_mode ( )

Checks if the system is currently in bootstrap mode.

Queries the system_settings table for the system.bootstrap_mode setting. If the setting is enabled (true), the system is in bootstrap mode.

Returns
true if system is in bootstrap mode, false otherwise

◆ initialize_bootstrap_state()

void initialize_bootstrap_state ( )

Initializes the bootstrap mode state on system startup.

This method should be called during service initialization. It ensures the bootstrap mode system setting exists and is set correctly based on whether admin accounts exist in the system.

Logic:

  • If setting doesn't exist and no admin accounts exist: create setting with enabled=true
  • If setting doesn't exist and admin accounts exist: create setting with enabled=false
  • If setting exists: verify it matches reality (admin accounts exist = setting should be false)

◆ exit_bootstrap_mode()

void exit_bootstrap_mode ( )

Transitions the system from bootstrap mode to secure mode.

This method is called after the first admin account is successfully created. It updates the system.bootstrap_mode system setting from enabled=true to enabled=false using bitemporal versioning.

This operation is idempotent - calling it when already in secure mode has no effect.

Here is the caller graph for this function: