- Fiche d'identité par organisation (technicien référent, FAI, IP publiques, prestataires liés) accessible depuis un nouveau menu. - Nouveau module Prestataires dédié (catalogue léger réutilisable entre communes, avec journal de suivi des échanges) plutôt que de détourner les organisations de type "Fournisseur". - Nouveau menu Infrastructure par organisation avec schémas réseau/fonctionnel édités via draw.io embarqué (URL configurable, cf. réglages admin). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
75 lines
3.2 KiB
PHP
75 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
/**
|
|
* Whitelist of settings administrators can override from the database instead
|
|
* of editing .env directly. Deliberately excludes anything read at the very
|
|
* start of the boot process (APP_KEY, DB_*, SESSION_DRIVER, CACHE_STORE,
|
|
* QUEUE_CONNECTION, ...): those are resolved before a database connection —
|
|
* or before this override even runs — so changing them here wouldn't
|
|
* reliably take effect, and getting DB_* wrong here could lock everyone out.
|
|
* Only settings that are safe to read lazily, at point of use, belong here.
|
|
*/
|
|
class SettingsRegistry
|
|
{
|
|
/**
|
|
* @var array<string, array<string, array{config: string, label: string}>>
|
|
*/
|
|
public const SETTINGS = [
|
|
'Application' => [
|
|
'APP_NAME' => ['config' => 'app.name', 'label' => "Nom de l'application"],
|
|
'APP_URL' => ['config' => 'app.url', 'label' => 'URL de base'],
|
|
],
|
|
'Mail' => [
|
|
'MAIL_MAILER' => ['config' => 'mail.default', 'label' => 'Pilote (mailer)'],
|
|
'MAIL_HOST' => ['config' => 'mail.mailers.smtp.host', 'label' => 'Hôte SMTP'],
|
|
'MAIL_PORT' => ['config' => 'mail.mailers.smtp.port', 'label' => 'Port SMTP'],
|
|
'MAIL_SCHEME' => ['config' => 'mail.mailers.smtp.scheme', 'label' => 'Schéma (tls, ssl…)'],
|
|
'MAIL_USERNAME' => ['config' => 'mail.mailers.smtp.username', 'label' => 'Utilisateur SMTP'],
|
|
'MAIL_PASSWORD' => ['config' => 'mail.mailers.smtp.password', 'label' => 'Mot de passe SMTP'],
|
|
'MAIL_FROM_ADDRESS' => ['config' => 'mail.from.address', 'label' => 'Adresse expéditeur'],
|
|
'MAIL_FROM_NAME' => ['config' => 'mail.from.name', 'label' => 'Nom expéditeur'],
|
|
],
|
|
'OnlyOffice' => [
|
|
'ONLYOFFICE_DS_URL' => ['config' => 'onlyoffice.document_server_url', 'label' => 'URL du serveur de documents'],
|
|
'ONLYOFFICE_CALLBACK_BASE_URL' => ['config' => 'onlyoffice.callback_base_url', 'label' => 'URL de rappel (callback)'],
|
|
'ONLYOFFICE_JWT_SECRET' => ['config' => 'onlyoffice.jwt_secret', 'label' => 'Secret JWT'],
|
|
],
|
|
'Draw.io' => [
|
|
'DRAWIO_URL' => ['config' => 'drawio.url', 'label' => "URL de l'éditeur draw.io"],
|
|
],
|
|
'GLPI' => [
|
|
'GLPI_API_URL' => ['config' => 'glpi.api_url', 'label' => "URL de l'API"],
|
|
'GLPI_APP_TOKEN' => ['config' => 'glpi.app_token', 'label' => 'Jeton application'],
|
|
'GLPI_USER_TOKEN' => ['config' => 'glpi.user_token', 'label' => 'Jeton utilisateur'],
|
|
'GLPI_CACHE_TTL' => ['config' => 'glpi.cache_ttl_seconds', 'label' => 'Durée du cache (secondes)'],
|
|
],
|
|
];
|
|
|
|
public const CACHE_KEY = 'settings.overrides';
|
|
|
|
public static function isSensitive(string $key): bool
|
|
{
|
|
return (bool) preg_match('/PASSWORD|SECRET|TOKEN|KEY/i', $key);
|
|
}
|
|
|
|
/**
|
|
* Flat env-style key => config path map, for applying overrides at boot.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public static function configMap(): array
|
|
{
|
|
$map = [];
|
|
|
|
foreach (self::SETTINGS as $section) {
|
|
foreach ($section as $envKey => $meta) {
|
|
$map[$envKey] = $meta['config'];
|
|
}
|
|
}
|
|
|
|
return $map;
|
|
}
|
|
}
|