Make server digest key a config option

This commit is contained in:
jvyden 2021-11-22 16:46:01 -05:00
commit 5e660fae18
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 6 additions and 5 deletions

View file

@ -1,10 +1,10 @@
using System;
using System.Diagnostics;
using System.IO;
using Kettu;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types.Settings;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@ -59,12 +59,12 @@ namespace LBPUnion.ProjectLighthouse
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
bool computeDigests = true;
string serverDigestKey = Environment.GetEnvironmentVariable("SERVER_DIGEST_KEY");
if (string.IsNullOrWhiteSpace(serverDigestKey))
string serverDigestKey = ServerSettings.Instance.ServerDigestKey;
if (string.IsNullOrEmpty(serverDigestKey))
{
Logger.Log
(
"The SERVER_DIGEST_KEY environment variable wasn't set, so digest headers won't be set or verified. This will prevent LBP 1 and LBP 3 from working. " +
"The serverDigestKey configuration option wasn't set, so digest headers won't be set or verified. This will also prevent LBP 1, LBP 2, and LBP Vita from working. " +
"To increase security, it is recommended that you find and set this variable.",
LoggerLevelStartup.Instance
);
@ -95,7 +95,7 @@ namespace LBPUnion.ProjectLighthouse
string digestPath = context.Request.Path;
Stream body = context.Request.Body;
if (computeDigests)
if (computeDigests && digestPath.StartsWith("/LITTLEBIGPLANETPS3_XML"))
{
string clientRequestDigest = await HashHelper.ComputeDigest(digestPath, authCookie, body, serverDigestKey);

View file

@ -89,5 +89,6 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
public string DbConnectionString { get; set; } = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
public string ExternalUrl { get; set; } = "http://localhost:10060";
public string ServerDigestKey { get; set; }
}
}