From f210cb335277b17a18ca01591223adad53e60e2d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Jul 2021 13:25:17 -0500 Subject: allow web un/pw to be changed at runtime --- .../Application/Management/API/Controllers/SessionController.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/slskd/Application/Management/API/Controllers') diff --git a/src/slskd/Application/Management/API/Controllers/SessionController.cs b/src/slskd/Application/Management/API/Controllers/SessionController.cs index 442970b9..02e8257e 100644 --- a/src/slskd/Application/Management/API/Controllers/SessionController.cs +++ b/src/slskd/Application/Management/API/Controllers/SessionController.cs @@ -15,6 +15,8 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // +using Microsoft.Extensions.Options; + namespace slskd.Management.API { using System; @@ -37,14 +39,17 @@ namespace slskd.Management.API public class SessionController : ControllerBase { public SessionController( + IOptionsSnapshot optionsSnapshot, OptionsAtStartup optionsAtStartup, SymmetricSecurityKey jwtSigningKey) { + OptionsSnapshot = optionsSnapshot; OptionsAtStartup = optionsAtStartup; JwtSigningKey = jwtSigningKey; } private SymmetricSecurityKey JwtSigningKey { get; set; } + private IOptionsSnapshot OptionsSnapshot { get; set; } private OptionsAtStartup OptionsAtStartup { get; set; } /// @@ -106,7 +111,7 @@ namespace slskd.Management.API } // only admin login for now - if (OptionsAtStartup.Web.Authentication.Username == login.Username && OptionsAtStartup.Web.Authentication.Password == login.Password) + if (OptionsSnapshot.Value.Web.Authentication.Username == login.Username && OptionsSnapshot.Value.Web.Authentication.Password == login.Password) { return Ok(new TokenResponse(GetJwtSecurityToken(login.Username, Role.Administrator))); } -- cgit v1.2.3