From 425086052873e49e23feea668c7e1b54fd239b12 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 1 Jan 2023 22:30:51 -0600 Subject: forbid config operations if remote config is disabled --- src/slskd/Core/API/Controllers/OptionsController.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/slskd/Core/API/Controllers/OptionsController.cs') diff --git a/src/slskd/Core/API/Controllers/OptionsController.cs b/src/slskd/Core/API/Controllers/OptionsController.cs index f621b37a..961571a0 100644 --- a/src/slskd/Core/API/Controllers/OptionsController.cs +++ b/src/slskd/Core/API/Controllers/OptionsController.cs @@ -86,6 +86,11 @@ namespace slskd.Core.API [ProducesResponseType(typeof(string), 200)] public IActionResult Debug() { + if (!OptionsAtStartup.Debug || !OptionsSnapshot.Value.RemoteConfiguration) + { + return Forbid(); + } + // retrieve the IConfigurationRoot instance with reflection to avoid // exposing it as a public member of Program. var property = typeof(Program).GetProperty("Configuration", BindingFlags.NonPublic | BindingFlags.Static); @@ -99,6 +104,11 @@ namespace slskd.Core.API [Route("yaml/location")] public IActionResult GetYamlFileLocation() { + if (!OptionsSnapshot.Value.RemoteConfiguration) + { + return Forbid(); + } + return Ok(Program.ConfigurationFile); } @@ -148,6 +158,11 @@ namespace slskd.Core.API [Route("yaml/validate")] public IActionResult ValidateYamlFile([FromBody] string yaml) { + if (!OptionsSnapshot.Value.RemoteConfiguration) + { + return Forbid(); + } + if (!TryValidateYaml(yaml, out var error)) { return Ok(error); -- cgit v1.2.3