Loading…
Loading…
Describes the JDBC-based cache for platform settings, which persists the last-known-good configuration to a database table for resilience and auditing.
The JdbcPlatformSettingsStore is a persistent, database-backed cache for platform-wide settings. It provides a "last-known-good" (LKG) store, ensuring that the system can operate with a valid configuration even if the primary settings source is temporarily unavailable.
This component solves two main problems:
If-None-Match requests, reducing data transfer. It also stores a pre-parsed JSON representation of the settings, avoiding the need to re-parse the JWT on every load.It is designed to be called by the central platform settings management service. When new settings are fetched, they are passed to the save method for persistence. When the application starts or needs to reload settings, it calls the loadLatest method.
A key feature of this component is its ability to audit changes to the "support break-glass" setting (support_consent_override), creating a clear record of when this override is enabled or disabled.
The JdbcPlatformSettingsStore uses a single database table, s2r_specaria_settings_cache, to store the platform settings. It operates on a single row in this table, identified by the fixed primary key id=1.
When settings are saved, the component performs an UPSERT operation (specifically, INSERT ... ON CONFLICT DO UPDATE) on the s2r_specaria_settings_cache table. This ensures that the single row is created if it doesn't exist or updated if it does.
The data is stored across several columns:
payload: A JSONB column containing the parsed configuration settings. The raw JWT is explicitly excluded from this payload.raw_jwt: The original, unmodified JWT string received from the settings provider. This is never logged.etag: The ETag header from the settings provider response, used for conditional polling.settings_version: The version number of the settings.fetched_at: The timestamp when the settings were originally fetched.The process of saving settings via the save method involves several steps to ensure data integrity and proper auditing.
sequenceDiagram
participant Caller
participant JdbcPlatformSettingsStore
participant Database
participant Audit Log Service
Caller->>+JdbcPlatformSettingsStore: save(settings, rawJwt, etag)
JdbcPlatformSettingsStore->>+Database: SELECT override FROM s2r_specaria_settings_cache
Database-->>-JdbcPlatformSettingsStore: Previous override value
JdbcPlatformSettingsStore->>+Database: UPSERT into s2r_specaria_settings_cache
Database-->>-JdbcPlatformSettingsStore: upsert result
Note over JdbcPlatformSettingsStore: Compares previous and new<br/>support_consent_override values
alt support_consent_override changed
JdbcPlatformSettingsStore->>+Audit Log Service: Write audit record
Audit Log Service-->>-JdbcPlatformSettingsStore: audit result
end
JdbcPlatformSettingsStore-->>-Caller: voidsupport_consent_override flag. This read is wrapped in an exception handler; if it fails, the operation continues, assuming the previous state was false.PlatformSettings object is serialized to a JSON string, and the upsert method is called to write the new settings, raw JWT, and ETag to the database.support_consent_override value with the new one.auditBreakGlassTransition method is invoked to log a WARN message and write a detailed audit event.The loadLatest method retrieves the cached settings from the database.
SELECT query on s2r_specaria_settings_cache for the row where id = 1.payload_json content is deserialized into a PlatformSettings object. If this parsing fails, a WARN is logged, and a minimal, empty PlatformSettings object is returned to prevent system failure.Stored object containing the PlatformSettings, the raw_jwt, and the etag.A critical function of this store is to create an audit trail for the support_consent_override flag, also known as the "support break-glass" mechanism.
When the save method detects a change in this boolean flag, it generates an audit event with the following characteristics:
system@platformsupport-consent.break-glass.on or support-consent.break-glass.off.support_consent. This specific type ensures the audit record is visible to deployment administrators, unlike other platform-level events.supportConsentOverride flag and the settingsVersion that introduced the change.This comparison is made against the value durably persisted in the database, not an in-memory value, which prevents false audit events after an application restart. If two instances save the same transition concurrently, both may write an audit record, following a principle of "over-audit, never under-audit".
The JdbcPlatformSettingsStore class implements the PlatformSettingsStore interface.
loadLatest()Loads the most recently saved platform settings from the database.
Optional<Stored> object.
Optional contains a Stored object wrapping the PlatformSettings, the raw JWT string, and the ETag string.Optional is empty.save(PlatformSettings settings, String rawJwt, String etag)Persists a new version of platform settings to the database and audits relevant changes.
settings (PlatformSettings): The parsed platform settings object to save.rawJwt (String): The raw, signed JWT from which the settings were derived.etag (String): The ETag associated with this version of the settings, for cache-invalidation.void.s2r_specaria_settings_cache database table.support_consent_override flag changes.WARN message upon a support_consent_override transition.The component relies on a specific database table and a JSON structure within it.
s2r_specaria_settings_cache Table| Column | Type | Description |
|---|---|---|
id | integer | The primary key, fixed to 1. |
settings_version | bigint | The version number from the PlatformSettings. |
raw_jwt | text | The complete, raw JWT string. |
etag | text | The ETag for the fetched settings, used for conditional polling. |
payload | jsonb | A JSON object containing the parsed configuration settings. See the schema below. |
fetched_at | timestamptz | The timestamp when the settings were originally fetched from the provider. |
updated_at | timestamptz | The timestamp when this database row was last updated. |
payload JSON SchemaThe payload column contains a JSON object with the following top-level fields.
| Field | Type | Required | Description |
|---|---|---|---|
customer_id | String | No | The unique identifier for the customer deployment. |
customer_display_name | String | No | The human-readable name for the customer deployment. |
deployment_mode | String | No | The deployment mode of the platform. |
public_base_url | String | No | The public base URL for the deployment. |
support_consent_override | Boolean | Yes | The "support break-glass" flag. If true, it permits support data capture, overriding local consent settings. Defaults to false if not present. |
region | Object | No | An object containing region settings. Includes allowed (array of strings), selected (string), and state (string). |
branding | Object | No | An object containing branding assets. Includes logo_url (string) and primary_locale (string). |
An example of the payload JSON structure:
{
"customer_id": "cust-12345",
"customer_display_name": "Example Corp",
"deployment_mode": "standard",
"public_base_url": "https://api.example.com",
"support_consent_override": false,
"region": {
"allowed": [
"us-east-1",
"eu-west-2"
],
"selected": "us-east-1",
"state": "ACTIVE"
},
"branding": {
"logo_url": "https://cdn.example.com/logo.png",
"primary_locale": "en-US"
}
}
The component logs specific messages to indicate its status or error conditions.
| Log Message | Level | Meaning |
|---|---|---|
S2R-SETTINGS could not read the stored break-glass flag: {message} | WARN | The database query to read the previous support_consent_override value failed. The save operation will proceed, but it will assume the previous value was false, which might result in an unnecessary audit event if the flag was already true. |
S2R-SETTINGS support-consent break-glass turned {ON/OFF} ... | WARN | A change in the support_consent_override flag was detected and persisted. This log confirms that the break-glass status has been changed by a new platform setting. |
S2R-SETTINGS break-glass audit write failed ({action}): {message} | ERROR | The component successfully saved a setting that changed the break-glass flag, but the corresponding audit event could not be written to the audit repository. The setting change is active, but the audit trail is incomplete. |
S2R-SETTINGS payload serialization failed (storing empty): {message} | WARN | An error occurred while serializing the PlatformSettings object to JSON. An empty JSON object ({}) will be stored in the payload column, which will likely cause data loss the next time settings are loaded from the cache. |
S2R-SETTINGS stored payload parse failed; returning minimal settings: {message} | WARN | During loadLatest, the JSON payload read from the database could not be parsed. The system will fall back to minimal default settings. This may alter system behavior until a new, valid configuration is fetched and saved. |