diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-08-23 18:10:29 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-08-23 18:10:29 -0500 |
| commit | 2c719dd8f5f330de61caf850c9087b5b989c1611 (patch) | |
| tree | 7ef5579f37acc67a731f2248fb3586f49459a339 /src/slskd/Core/API/Controllers/LogsController.cs | |
| parent | 8133ee872bfe07e859fc09bf6ea7062c08249ecb (diff) | |
| download | slskd-2c719dd8f5f330de61caf850c9087b5b989c1611.tar.gz | |
docs, change routes, lock endpoints down to administrators only
Diffstat (limited to 'src/slskd/Core/API/Controllers/LogsController.cs')
| -rw-r--r-- | src/slskd/Core/API/Controllers/LogsController.cs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/slskd/Core/API/Controllers/LogsController.cs b/src/slskd/Core/API/Controllers/LogsController.cs index a12d9187..465993c1 100644 --- a/src/slskd/Core/API/Controllers/LogsController.cs +++ b/src/slskd/Core/API/Controllers/LogsController.cs @@ -67,15 +67,19 @@ namespace slskd.Core.API /// Gets the last few application logs. /// </summary> /// <returns></returns> - [HttpGet("buffer")] - [Authorize(Policy = AuthPolicy.Any)] + [HttpGet("live")] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.AdministratorOnly)] public IActionResult Logs() { return Ok(Program.LogBuffer); } - [HttpGet] - [Authorize(Policy = AuthPolicy.Any)] + /// <summary> + /// Lists the log files currently on disk. + /// </summary> + /// <returns></returns> + [HttpGet("files")] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.AdministratorOnly)] public async Task<IActionResult> List() { var directory = await Files.ListDirectoryContentsAsync(System.IO.Path.GetFullPath(Program.LogDirectory), enumerationOptions: new EnumerationOptions @@ -87,8 +91,14 @@ namespace slskd.Core.API return Ok(directory.Files); } - [HttpGet("{filename}")] - [Authorize(Policy = AuthPolicy.Any)] + /// <summary> + /// Retrieves the requested log file from disk. + /// </summary> + /// <param name="filename"></param> + /// <param name="download"></param> + /// <returns></returns> + [HttpGet("files/{filename}")] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.AdministratorOnly)] public async Task<IActionResult> Get(string filename, [FromQuery] bool download = false) { filename = FileSafety.GetFileNameSafely(filename); |
