Set the expiry time in 5 minutes
MODIFY
src/WebJobs.Script.WebHost/Controllers/HostController.cs
src/WebJobs.Script.WebHost/Controllers/HostController.cs
@@ -248,7 +248,7 @@ public IActionResult GetAdminToken()
return BadRequest("Endpoint is only available when running in Linux Container");
}
- string requestHeaderToken = SimpleWebTokenHelper.CreateToken(DateTime.UtcNow.AddHours(2));
+ string requestHeaderToken = SimpleWebTokenHelper.CreateToken(DateTime.UtcNow.AddMinutes(5));
return Ok(requestHeaderToken);
}

MODIFY
test/WebJobs.Script.Tests/Controllers/Admin/HostControllerTests.cs
test/WebJobs.Script.Tests/Controllers/Admin/HostControllerTests.cs
using System.IO;
using System.Net;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs.Script.WebHost.Controllers;
using Microsoft.Azure.WebJobs.Script.WebHost.Management;
+using Microsoft.Azure.WebJobs.Script.WebHost.Security;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.WebJobs.Script.Tests;
@@ -104,9 +106,11 @@ public void GetAdminToken_Succeeds()
// Act
ObjectResult result = (ObjectResult)_hostController.GetAdminToken();
HttpStatusCode resultStatus = (HttpStatusCode)result.StatusCode;
+ string token = (string)result.Value;
// Assert
Assert.Equal(HttpStatusCode.OK, resultStatus);
+ Assert.True(SimpleWebTokenHelper.ValidateToken(token, new SystemClock()));
}
}

Set the expiry time in 5 minutes