aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Core/API/Controllers/OptionsController.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-01-01 22:30:51 -0600
committerJP Dillingham <jp@dillingham.me>2023-01-01 22:30:51 -0600
commit425086052873e49e23feea668c7e1b54fd239b12 (patch)
treec5cc1465d8d8218df863d23c77dcd193c1e96ebd /src/slskd/Core/API/Controllers/OptionsController.cs
parent22ffe499c022bff90c76b6519dbca3850cfa41f8 (diff)
downloadslskd-425086052873e49e23feea668c7e1b54fd239b12.tar.gz
forbid config operations if remote config is disabled
Diffstat (limited to 'src/slskd/Core/API/Controllers/OptionsController.cs')
-rw-r--r--src/slskd/Core/API/Controllers/OptionsController.cs15
1 files changed, 15 insertions, 0 deletions
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);