Browse Source

Forbid tasks.json modification on production env

mj-deploy
Standa Lukeš 4 years ago
parent
commit
a2797cabc2
  1. 4
      server/Ksp.WebServer/Controllers/TasksController.cs

4
server/Ksp.WebServer/Controllers/TasksController.cs

@ -5,6 +5,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Ksp.WebServer.Controllers
@ -33,6 +34,9 @@ namespace Ksp.WebServer.Controllers
[HttpPost]
public async Task<IActionResult> Post()
{
if (env.IsProduction())
return this.Forbid();
// TODO: auth org
using var rdr = new StreamReader(HttpContext.Request.Body);
await System.IO.File.WriteAllTextAsync(TasksJsonFile, await rdr.ReadToEndAsync());