chore: Fix issues with autoconf: globally set settings overridden by default values not being saved correctly in database

This commit is contained in:
Théophile Diot 2024-07-11 16:43:54 +01:00
parent c4d8a308b1
commit 0579c79d51
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
2 changed files with 12 additions and 3 deletions

View file

@ -7,6 +7,7 @@
- [BUGFIX] Fix issues with kubernetes integration when were setting a global multisite setting it was not applied to the services
- [UI] Update web UI setup wizard to handle when a reverse proxy already exists but no admin user is configured
- [UI] Fix issues with multiple settings on the global_config not being able to be deleted in specific cases
- [AUTOCONF] Fix issues with globally set settings overridden by default values not being saved correctly in database
- [SECURITY] Update security headers in default pages and error pages for improved security
- [DEPS] Updated LuaJIT version to v2.1-20240626
- [DEPS] Updated coreruleset-v4 version to v4.4.0

View file

@ -1250,6 +1250,10 @@ class Database:
changed_plugins.add(session.query(Settings).with_entities(Settings.plugin_id).filter_by(id=db_service_config.setting_id).first().plugin_id)
if config:
db_global_config = {}
if method == "autoconf":
db_global_config = self.get_non_default_settings(global_only=True)
config.pop("DATABASE_URI", None)
db_services = session.query(Services).with_entities(Services.id, Services.method, Services.is_draft).all()
db_ids: Dict[str, dict] = {service.id: {"method": service.method, "is_draft": service.is_draft} for service in db_services}
@ -1338,7 +1342,9 @@ class Database:
if not service_setting:
if key != "SERVER_NAME" and (
(original_key not in config and value == setting.default) or (original_key in config and value == config[original_key])
(original_key not in config and original_key not in db_global_config and value == setting.default)
or (original_key in config and value == config[original_key])
or (original_key in db_global_config and value == db_global_config[original_key])
):
continue
@ -1355,7 +1361,9 @@ class Database:
)
if key != "SERVER_NAME" and (
(original_key not in config and value == setting.default) or (original_key in config and value == config[original_key])
(original_key not in config and original_key not in db_global_config and value == setting.default)
or (original_key in config and value == config[original_key])
or (original_key in db_global_config and value == db_global_config[original_key])
):
query.delete()
continue
@ -1386,7 +1394,7 @@ class Database:
query.delete()
continue
query.update({Global_values.value: value, Global_values.method: method})
else:
elif method != "autoconf":
if (
config.get("SERVER_NAME", "www.example.com")
and not session.query(Services)