aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-03-02 16:21:06 -0600
committerGitHub <noreply@github.com>2024-03-02 16:21:06 -0600
commitb98bd9a523680a93164754ef31250f97787775fc (patch)
tree10fc300c5d8a6836ead1d203d3e6d9551015f188 /src
parent9b2269a5501fd6b971473f6dd08e632f1ee5238d (diff)
parent9393e973873d637f7c3776437cbeaddeae808d70 (diff)
downloadslskd-b98bd9a523680a93164754ef31250f97787775fc.tar.gz
Merge pull request #1090 from slskd/deprecate
Raise lower limit for JWT signing key from 16 to 32 characters
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs2
-rw-r--r--src/slskd/Program.cs11
2 files changed, 2 insertions, 11 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index c64da46a..cfe78eb1 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1725,7 +1725,7 @@ namespace slskd
[Argument(default, "jwt-key")]
[EnvironmentVariable("JWT_KEY")]
[Description("JWT signing key")]
- [StringLength(255, MinimumLength = 16)]
+ [StringLength(255, MinimumLength = 32)]
[Secret]
[RequiresRestart]
public string Key { get; init; } = Cryptography.Random.GetBytes(32).ToBase62();
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index ad50dccd..d7f6caca 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -634,16 +634,7 @@ namespace slskd
services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(DataDirectory, "misc", ".DataProtection-Keys")));
- var adjustedJwtKey = OptionsAtStartup.Web.Authentication.Jwt.Key;
-
- // the JWT key must be at least 256 bits in length, due to the HMACSHA256 algorithm being used for signing.
- if (adjustedJwtKey.Length < 32)
- {
- adjustedJwtKey = adjustedJwtKey.PadRight(32, ' ');
- Log.Warning("The configured JWT signing key is less than the required 32 characters and has been padded with spaces to make up the difference. The minimum length will be raised from 16 to 32 in a future release, and this will become an error.");
- }
-
- var jwtSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(adjustedJwtKey));
+ var jwtSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(OptionsAtStartup.Web.Authentication.Jwt.Key));
services.AddSingleton(jwtSigningKey);
services.AddSingleton<ISecurityService, SecurityService>();