1. Overview
The IdentityLeakConfig.hpp header defines the IdentityLeakConfig utility class, responsible for managing configuration settings related to identity leak monitoring and external breach-detection services. This component provides centralized access to API credentials and monitoring preferences using a persistent JSON-based configuration model.
Functionally, IdentityLeakConfig provides:
- Secure storage and retrieval of third-party API keys
- Enable/disable control for identity monitoring services
- JSON-based persistent configuration management
- Stateless, static accessors for global configuration values
2. Dependencies and Includes
#include <string>
#include <nlohmann/json.hpp>
- <string> – storage and handling of textual configuration values
- nlohmann/json.hpp – JSON parsing, serialization, and structured data handling
3. Class Declaration and Scope
class IdentityLeakConfig
The IdentityLeakConfig class is implemented as a static configuration manager. It does not require instantiation and exposes all functionality through static member functions.
4. Public Interface
4.1 API Key Management
static std::string hibpApiKey();
static void setHibpApiKey(const std::string&);
static std::string leakCheckApiKey();
static void setLeakCheckApiKey(const std::string&);
Provides getter and setter functions for API credentials used to communicate with external breach monitoring services, such as Have I Been Pwned (HIBP) and LeakCheck.
4.2 Monitoring Controls
static bool monitorEnabled();
static void setMonitorEnabled(bool);
Enables or disables the identity monitoring subsystem through a persistent configuration flag.
5. Internal Architecture
5.1 Filesystem Integration
static std::string configPath();
Resolves the absolute path to the JSON configuration file used to store identity monitoring settings.
5.2 JSON Persistence Helpers
static nlohmann::json loadJson();
static void saveJson(const nlohmann::json& j);
Internal helper methods responsible for loading and persisting configuration data using structured JSON serialization.
6. Configuration Data Model
The underlying JSON document managed by IdentityLeakConfig typically includes:
- hibp_api_key – credential for Have I Been Pwned API access
- leakcheck_api_key – credential for LeakCheck service access
- monitor_enabled – boolean flag controlling active monitoring
7. Usage Patterns
- Initialization of monitoring services during application startup
- Dynamic enable/disable of breach monitoring from user preferences
- Secure injection of API keys into network service clients
- Centralized configuration access for security modules
8. Security and Reliability Considerations
- Credential protection: API keys should be stored using restricted filesystem permissions and, where possible, encrypted at rest
- Atomic writes: configuration updates should use temporary files and atomic renames to prevent corruption
- Input validation: setter methods should validate key format before persistence
- Error handling: JSON parsing and I/O failures should be logged and surfaced to calling components
- Thread safety: concurrent access should be serialized or protected by appropriate synchronization primitives