add FoxchatError type
This commit is contained in:
parent
f6629fbb33
commit
d34c41a126
7 changed files with 42 additions and 20 deletions
|
@ -27,7 +27,7 @@ public partial class RequestSigningService(ILogger logger, IClock clock, IDataba
|
|||
formatter.SetHashAlgorithm(nameof(SHA256));
|
||||
var signature = formatter.CreateSignature(hash);
|
||||
|
||||
_logger.Debug("Generated signature for {Host} {RequestPath}: {Signature}", data.Host, data.RequestPath, WebEncoders.Base64UrlEncode(signature));
|
||||
_logger.Debug("Generated signature for {Host} {RequestPath}", data.Host, data.RequestPath);
|
||||
return WebEncoders.Base64UrlEncode(signature);
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,11 @@ public partial class RequestSigningService(ILogger logger, IClock clock, IDataba
|
|||
var time = ParseTime(dateHeader);
|
||||
if ((now + Duration.FromMinutes(1)) < time)
|
||||
{
|
||||
// TODO: replace this with specific exception type
|
||||
throw new Exception("Request was made in the future");
|
||||
throw new FoxchatError.IncomingFederationError("Request was made in the future");
|
||||
}
|
||||
else if ((now - Duration.FromMinutes(1)) > time)
|
||||
{
|
||||
// TODO: replace this with specific exception type
|
||||
throw new Exception("Request was made too long ago");
|
||||
throw new FoxchatError.IncomingFederationError("Request was made too long ago");
|
||||
}
|
||||
|
||||
var plaintext = GeneratePlaintext(new SignatureData(time, host, requestPath, contentLength, userId));
|
||||
|
@ -67,8 +65,6 @@ public partial class RequestSigningService(ILogger logger, IClock clock, IDataba
|
|||
var contentLength = data.ContentLength != null ? data.ContentLength.ToString() : "";
|
||||
var userId = data.UserId ?? "";
|
||||
|
||||
Log.Information("Plaintext string: {Plaintext}", $"{time}:{data.Host}:{data.RequestPath}:{contentLength}:{userId}");
|
||||
|
||||
return $"{time}:{data.Host}:{data.RequestPath}:{contentLength}:{userId}";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue