ORE Studio 0.0.4
Loading...
Searching...
No Matches
system_settings.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_VARIABILITY_DOMAIN_SYSTEM_SETTINGS_HPP
21#define ORES_VARIABILITY_DOMAIN_SYSTEM_SETTINGS_HPP
22
23#include <array>
24#include <string_view>
25#include <stdexcept>
26
28
37 std::string_view name;
38 std::string_view data_type; // "boolean" | "integer" | "string" | "json"
39 std::string_view default_value;
40 std::string_view description;
41};
42
49inline constexpr std::array system_setting_definitions = {
51 .name = "system.bootstrap_mode",
52 .data_type = "boolean",
53 .default_value = "true",
54 .description = "Indicates whether the system is in bootstrap mode "
55 "(waiting for initial admin account)."
56 },
58 .name = "system.user_signups",
59 .data_type = "boolean",
60 .default_value = "false",
61 .description = "Controls whether user self-registration is allowed."
62 },
64 .name = "system.signup_requires_authorization",
65 .data_type = "boolean",
66 .default_value = "false",
67 .description = "Controls whether new signups require admin authorization. "
68 "NOT YET IMPLEMENTED - enabling will cause signup to fail."
69 },
71 .name = "system.disable_password_validation",
72 .data_type = "boolean",
73 .default_value = "false",
74 .description = "When enabled, disables strict password validation. "
75 "FOR TESTING/DEVELOPMENT ONLY."
76 },
78 .name = "system.synthetic_data_generation",
79 .data_type = "boolean",
80 .default_value = "false",
81 .description = "Enables synthetic test data generation in the UI. "
82 "FOR TESTING/DEVELOPMENT ONLY."
83 },
84 // -------------------------------------------------------------------------
85 // IAM token lifetime settings
86 // -------------------------------------------------------------------------
88 .name = "iam.token.access_lifetime_seconds",
89 .data_type = "integer",
90 .default_value = "1800",
91 .description = "Lifetime in seconds of every issued JWT access token. "
92 "Default is 1800 (30 minutes)."
93 },
95 .name = "iam.token.party_selection_lifetime_seconds",
96 .data_type = "integer",
97 .default_value = "300",
98 .description = "Lifetime in seconds of the short-lived party-selection "
99 "step token. Default is 300 (5 minutes)."
100 },
102 .name = "iam.token.max_session_seconds",
103 .data_type = "integer",
104 .default_value = "28800",
105 .description = "Hard ceiling in seconds after which a session must "
106 "re-authenticate regardless of refresh activity. Default is 28800 (8 hours)."
107 },
109 .name = "iam.token.refresh_threshold_pct",
110 .data_type = "integer",
111 .default_value = "80",
112 .description = "Percentage of token lifetime at which the client "
113 "proactively requests a token refresh. Default is 80 (80%)."
114 }
115};
116
122[[nodiscard]] inline const system_setting_definition&
123get_setting_definition(std::string_view name) {
124 for (const auto& def : system_setting_definitions) {
125 if (def.name == name)
126 return def;
127 }
128 throw std::out_of_range(
129 std::string("System setting definition not found: ") + std::string(name));
130}
131
137[[nodiscard]] inline std::string_view
138get_setting_default(std::string_view name) {
139 return get_setting_definition(name).default_value;
140}
141
142}
143
144#endif
Domain types for system variability.
Definition ores.variability.api.domain.hpp:27
const system_setting_definition & get_setting_definition(std::string_view name)
Looks up a setting definition by name.
Definition system_settings.hpp:123
std::string_view get_setting_default(std::string_view name)
Returns the default value for a registered setting name.
Definition system_settings.hpp:138
constexpr std::array system_setting_definitions
Compile-time registry of all well-known system settings.
Definition system_settings.hpp:49
Metadata for a well-known system setting.
Definition system_settings.hpp:36