mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 11:58:38 +00:00
Fix issue where the server will 403 you if SERVER_DIGEST_KEY env var is unset.
This commit is contained in:
parent
76ed7a736d
commit
874477008e
1 changed files with 16 additions and 12 deletions
|
@ -77,23 +77,27 @@ namespace LBPUnion.ProjectLighthouse
|
|||
string digestPath = context.Request.Path;
|
||||
Stream body = context.Request.Body;
|
||||
|
||||
string clientRequestDigest = await HashHelper.ComputeDigest(digestPath, authCookie, body, serverDigestKey);
|
||||
|
||||
// Check the digest we've just calculated against the X-Digest-A header if the game set the header. They should match.
|
||||
if (context.Request.Headers.TryGetValue("X-Digest-A", out var sentDigest))
|
||||
if (computeDigests)
|
||||
{
|
||||
if (clientRequestDigest != sentDigest)
|
||||
string clientRequestDigest =
|
||||
await HashHelper.ComputeDigest(digestPath, authCookie, body, serverDigestKey);
|
||||
|
||||
// Check the digest we've just calculated against the X-Digest-A header if the game set the header. They should match.
|
||||
if (context.Request.Headers.TryGetValue("X-Digest-A", out var sentDigest))
|
||||
{
|
||||
context.Response.StatusCode = 403;
|
||||
context.Abort();
|
||||
return;
|
||||
if (clientRequestDigest != sentDigest)
|
||||
{
|
||||
context.Response.StatusCode = 403;
|
||||
context.Abort();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
context.Response.Headers.Add("X-Digest-B", clientRequestDigest);
|
||||
context.Request.Body.Position = 0;
|
||||
}
|
||||
|
||||
context.Response.Headers.Add("X-Digest-B", clientRequestDigest);
|
||||
context.Request.Body.Position = 0;
|
||||
|
||||
// This does the same as above, but for the response stream.
|
||||
// This does the same as above, but for the response stream.
|
||||
using MemoryStream responseBuffer = new MemoryStream();
|
||||
Stream oldResponseStream = context.Response.Body;
|
||||
context.Response.Body = responseBuffer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue