diff --git a/backend/SpMega.Backend/Program.cs b/backend/SpMega.Backend/Program.cs index 5faa6ca..53af444 100644 --- a/backend/SpMega.Backend/Program.cs +++ b/backend/SpMega.Backend/Program.cs @@ -19,8 +19,10 @@ public class Program .AddJsonFile("appsettings.Development.json", true) .AddEnvironmentVariables(); - var encryptionKey = builder.Configuration["Encryption:Key"] ?? "a-default-fallback-only-for-dev-key-change-this!"; + var conf = builder.Configuration; + var encryptionKey = conf["Encryption:Key"] ?? "a-default-fallback-only-for-dev-key-change-this!"; EncryptionHelper.Initialize(encryptionKey); + _ = conf["JWT:Secret"] ?? conf["JWT__Secret"] ?? throw new InvalidOperationException("JWT__Secret is not configured."); builder.Services.AddAuthorization(); builder.Services.AddLogging(logging => diff --git a/backend/SpMega.Backend/Services/TokenService.cs b/backend/SpMega.Backend/Services/TokenService.cs index 2788c00..ebfc29d 100644 --- a/backend/SpMega.Backend/Services/TokenService.cs +++ b/backend/SpMega.Backend/Services/TokenService.cs @@ -8,8 +8,8 @@ namespace SpMega.Backend.Services; public class TokenService(IConfiguration conf) { private const int AccessTokenExpirationMinutes = 24; - private readonly string _issuer = conf["JWT__Issuer"] ?? "spmega.il.yawaflua.tech"; - private readonly string _secret = conf["JWT__Secret"] ?? throw new InvalidOperationException("JWT__Secret is not configured."); + private readonly string _issuer = conf["JWT:Issuer"] ?? conf["JWT__Issuer"] ?? "spmega.il.yawaflua.tech"; + private readonly string _secret = conf["JWT:Secret"] ?? conf["JWT__Secret"] ?? throw new InvalidOperationException("JWT__Secret is not configured."); public string GenerateAccessToken(string userName, Guid uuid) {