aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Network/NetworkService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-10-26 09:56:38 -0500
committerJP Dillingham <jp@dillingham.me>2022-10-26 09:56:38 -0500
commit20b800a3bdd9b0022b0e1870364980068c3d4adf (patch)
tree0e38dd41740f80471ec5a8100f13e8b8b3ba49a8 /src/slskd/Network/NetworkService.cs
parent7510f1d4165bdff9f3c656cd31b5ba883fb6cb18 (diff)
downloadslskd-20b800a3bdd9b0022b0e1870364980068c3d4adf.tar.gz
tweak auth
Diffstat (limited to 'src/slskd/Network/NetworkService.cs')
-rw-r--r--src/slskd/Network/NetworkService.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/slskd/Network/NetworkService.cs b/src/slskd/Network/NetworkService.cs
index 0a3079ae..100d9448 100644
--- a/src/slskd/Network/NetworkService.cs
+++ b/src/slskd/Network/NetworkService.cs
@@ -187,9 +187,9 @@ namespace slskd.Network
/// </summary>
/// <param name="connectionId">The ID of the agent connection.</param>
/// <param name="agentName">The agent name.</param>
- /// <param name="challengeResponse">The challenge response provided by the agent.</param>
+ /// <param name="credential">The response credential.</param>
/// <returns>A value indicating whether the response is valid.</returns>
- bool TryValidateAuthenticationChallengeResponse(string connectionId, string agentName, string challengeResponse);
+ bool TryValidateAuthenticationCredential(string connectionId, string agentName, string credential);
/// <summary>
/// Attempts to validate the file stream response credential associated with the specified <paramref name="token"/>.
@@ -257,7 +257,7 @@ namespace slskd.Network
var token = Cryptography.Random.GetBytes(32).ToBase62();
// this token is only valid for this connection id for a short time this is important to prevent replay-type attacks.
- MemoryCache.Set(GetAuthTokenCacheKey(connectionId), token, TimeSpan.FromMinutes(1));
+ MemoryCache.Set(GetAuthTokenCacheKey(connectionId), token, TimeSpan.FromSeconds(10));
Log.Debug("Cached auth token {Token} for ID {Id}", token, connectionId);
return token;
}
@@ -532,9 +532,9 @@ namespace slskd.Network
/// </summary>
/// <param name="connectionId">The ID of the agent connection.</param>
/// <param name="agentName">The agent name.</param>
- /// <param name="challengeResponse">The challenge response provided by the agent.</param>
+ /// <param name="credential">The response credential.</param>
/// <returns>A value indicating whether the response is valid.</returns>
- public bool TryValidateAuthenticationChallengeResponse(string connectionId, string agentName, string challengeResponse)
+ public bool TryValidateAuthenticationCredential(string connectionId, string agentName, string credential)
{
if (!MemoryCache.TryGetValue(GetAuthTokenCacheKey(connectionId), out var challengeToken))
{
@@ -552,7 +552,7 @@ namespace slskd.Network
var tokenBytes = ((string)challengeToken).FromBase62();
var expectedResponse = Aes.Encrypt(tokenBytes, key).ToBase62();
- return expectedResponse == challengeResponse;
+ return expectedResponse == credential;
}
/// <summary>