This commit is contained in:
Josh 2024-11-16 17:04:16 -06:00 committed by GitHub
commit e490795ceb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 288 additions and 389 deletions

View file

@ -1,9 +1,9 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter; using LBPUnion.ProjectLighthouse.Types.Filter;
@ -11,17 +11,12 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController] public class CommentController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class CommentController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;
public CommentController(DatabaseContext database) public CommentController(DatabaseContext database)

View file

@ -1,14 +1,10 @@
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using Microsoft.AspNetCore.Authorization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController] public class DeveloperController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class DeveloperController : Controller
{ {
[HttpGet("developer_videos")] [HttpGet("developer_videos")]
public IActionResult DeveloperVideos() => this.Ok(new GameDeveloperVideos()); public IActionResult DeveloperVideos() => this.Ok(new GameDeveloperVideos());

View file

@ -1,23 +1,18 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
using LBPUnion.ProjectLighthouse.StorableLists.Stores; using LBPUnion.ProjectLighthouse.StorableLists.Stores;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController] public class FriendsController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class FriendsController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,22 +1,18 @@
#nullable enable
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Login; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Login;
[ApiController]
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/plain")] [Produces("text/plain")]
public class ClientConfigurationController : ControllerBase public class ClientConfigurationController : GameController
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;
@ -26,6 +22,7 @@ public class ClientConfigurationController : ControllerBase
} }
[HttpGet("network_settings.nws")] [HttpGet("network_settings.nws")]
[UseDigest(EnforceDigest = false)]
[SuppressMessage("ReSharper", "StringLiteralTypo")] [SuppressMessage("ReSharper", "StringLiteralTypo")]
public IActionResult NetworkSettings() public IActionResult NetworkSettings()
{ {
@ -41,15 +38,18 @@ public class ClientConfigurationController : ControllerBase
[HttpGet("t_conf")] [HttpGet("t_conf")]
[Produces("text/xml")] [Produces("text/xml")]
[UseDigest(EnforceDigest = false)]
public IActionResult Conf() => this.Ok(new TelemetryConfigResponse()); public IActionResult Conf() => this.Ok(new TelemetryConfigResponse());
// The challenge config here is currently based on the official server's config. // The challenge config here is currently based on the official server's config.
// We should probably make this configurable in the future. // We should probably make this configurable in the future.
[HttpGet("ChallengeConfig.xml")] [HttpGet("ChallengeConfig.xml")]
[Produces("text/xml")] [Produces("text/xml")]
[UseDigest(EnforceDigest = false)]
public IActionResult Challenges() => this.Ok(GameChallengeResponse.ServerChallenges()); public IActionResult Challenges() => this.Ok(GameChallengeResponse.ServerChallenges());
[HttpGet("farc_hashes")] [HttpGet("farc_hashes")]
[UseDigest(EnforceDigest = false)]
public IActionResult FarcHashes() => this.Ok(); public IActionResult FarcHashes() => this.Ok();
[HttpGet("privacySettings")] [HttpGet("privacySettings")]

View file

@ -1,20 +1,15 @@
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Login; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Login;
[ApiController] public class LogoutController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/goodbye")]
[Produces("text/xml")]
public class LogoutController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;
public LogoutController(DatabaseContext database) public LogoutController(DatabaseContext database)
@ -22,8 +17,8 @@ public class LogoutController : ControllerBase
this.database = database; this.database = database;
} }
[HttpPost] [HttpPost("goodbye")]
public async Task<IActionResult> OnPost() public async Task<IActionResult> OnLogout()
{ {
GameTokenEntity token = this.GetToken(); GameTokenEntity token = this.GetToken();
@ -37,6 +32,4 @@ public class LogoutController : ControllerBase
return this.Ok(); return this.Ok();
} }
} }

View file

@ -1,22 +1,17 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[ApiController] public class EnterLevelController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class EnterLevelController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,27 +1,22 @@
#nullable enable
using System.Text.Json; using System.Text.Json;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Matchmaking; using LBPUnion.ProjectLighthouse.Types.Matchmaking;
using LBPUnion.ProjectLighthouse.Types.Matchmaking.MatchCommands; using LBPUnion.ProjectLighthouse.Types.Matchmaking.MatchCommands;
using LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms; using LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[ApiController] public class MatchController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class MatchController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -7,23 +7,20 @@ using LBPUnion.ProjectLighthouse.Localization;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Notifications; using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Mail; using LBPUnion.ProjectLighthouse.Types.Mail;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController]
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/plain")] [Produces("text/plain")]
public class MessageController : ControllerBase public class MessageController : GameController
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;
@ -47,9 +44,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
} }
[HttpGet("eula")] [HttpGet("eula")]
[UseDigest(EnforceDigest = false)]
public IActionResult Eula() => this.Ok($"{license}\n{ServerConfiguration.Instance.EulaText}"); public IActionResult Eula() => this.Ok($"{license}\n{ServerConfiguration.Instance.EulaText}");
[HttpGet("announce")] [HttpGet("announce")]
[UseDigest(EnforceDigest = false)]
public async Task<IActionResult> Announce() public async Task<IActionResult> Announce()
{ {
GameTokenEntity token = this.GetToken(); GameTokenEntity token = this.GetToken();

View file

@ -1,24 +1,19 @@
#nullable enable using System.Text.Json;
using System.Text.Json;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Moderation.Reports; using LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController] public class ReportController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class ReportController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,4 +1,3 @@
#nullable enable
using Discord; using Discord;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
@ -6,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -13,17 +13,12 @@ using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources;
[ApiController] public class PhotosController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class PhotosController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,23 +1,18 @@
#nullable enable
using System.Text; using System.Text;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Misc; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Misc;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Resources; using LBPUnion.ProjectLighthouse.Types.Resources;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using IOFile = System.IO.File; using IOFile = System.IO.File;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources;
[ApiController] public class ResourcesController : GameController
[Authorize]
[Produces("text/xml")]
[Route("LITTLEBIGPLANETPS3_XML")]
public class ResourcesController : ControllerBase
{ {
[HttpPost("showModerated")] [HttpPost("showModerated")]
@ -52,6 +47,7 @@ public class ResourcesController : ControllerBase
[HttpPost("upload/{hash}/unattributed")] [HttpPost("upload/{hash}/unattributed")]
[HttpPost("upload/{hash}")] [HttpPost("upload/{hash}")]
[UseDigest(DigestHeaderName = "X-Digest-B", ExcludeBodyFromDigest = true)]
public async Task<IActionResult> UploadResource(string hash) public async Task<IActionResult> UploadResource(string hash)
{ {
string assetsDirectory = FileHelper.ResourcePath; string assetsDirectory = FileHelper.ResourcePath;

View file

@ -4,6 +4,7 @@ using LBPUnion.ProjectLighthouse.Filter;
using LBPUnion.ProjectLighthouse.Filter.Sorts; using LBPUnion.ProjectLighthouse.Filter.Sorts;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions; using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Categories; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Categories;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -13,17 +14,12 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Misc; using LBPUnion.ProjectLighthouse.Types.Misc;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class CategoryController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class CategoryController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,22 +1,18 @@
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class LevelTagsController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML")]
[Produces("text/plain")]
public class LevelTagsController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,9 +1,9 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Filter; using LBPUnion.ProjectLighthouse.Filter;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions; using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -11,17 +11,12 @@ using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class ListController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class ListController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,21 +1,16 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class PlaylistController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class PlaylistController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -6,6 +6,7 @@ using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers; using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -23,7 +24,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Authorize] [Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")] [Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")] [Produces("text/xml")]
public class PublishController : ControllerBase public class PublishController : GameController
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -3,22 +3,18 @@ using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter; using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class ReviewController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class ReviewController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,8 +1,8 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.StorableLists.Stores; using LBPUnion.ProjectLighthouse.StorableLists.Stores;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -10,17 +10,12 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class ScoreController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class ScoreController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,25 +1,20 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Filter; using LBPUnion.ProjectLighthouse.Filter;
using LBPUnion.ProjectLighthouse.Filter.Filters; using LBPUnion.ProjectLighthouse.Filter.Filters;
using LBPUnion.ProjectLighthouse.Filter.Sorts; using LBPUnion.ProjectLighthouse.Filter.Sorts;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions; using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter; using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class SearchController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/slots")]
[Produces("text/xml")]
public class SearchController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;
public SearchController(DatabaseContext database) public SearchController(DatabaseContext database)

View file

@ -1,4 +1,3 @@
#nullable enable
using System.Linq.Expressions; using System.Linq.Expressions;
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
@ -8,6 +7,7 @@ using LBPUnion.ProjectLighthouse.Filter.Sorts;
using LBPUnion.ProjectLighthouse.Filter.Sorts.Metadata; using LBPUnion.ProjectLighthouse.Filter.Sorts.Metadata;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions; using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter; using LBPUnion.ProjectLighthouse.Types.Filter;
@ -15,17 +15,12 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Misc; using LBPUnion.ProjectLighthouse.Types.Misc;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[ApiController] public class SlotsController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class SlotsController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,20 +1,17 @@
using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Filter; using LBPUnion.ProjectLighthouse.Filter;
using LBPUnion.ProjectLighthouse.Filter.Filters; using LBPUnion.ProjectLighthouse.Filter.Filters;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions; using LBPUnion.ProjectLighthouse.Servers.GameServer.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController]
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/plain")] [Produces("text/plain")]
public class StatisticsController : ControllerBase public class StatisticsController : GameController
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,13 +1,9 @@
using Microsoft.AspNetCore.Authorization; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController] public class StoreController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class StoreController : Controller
{ {
[HttpGet("promotions")] [HttpGet("promotions")]
public IActionResult Promotions() => this.Ok(); public IActionResult Promotions() => this.Ok();

View file

@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers; using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -13,17 +14,12 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Serialization; using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController] public class UserController : GameController
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class UserController : ControllerBase
{ {
private readonly DatabaseContext database; private readonly DatabaseContext database;

View file

@ -1,7 +1,7 @@
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using Org.BouncyCastle.Utilities.Zlib; using Org.BouncyCastle.Utilities.Zlib;
@ -9,108 +9,17 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
public class DigestMiddleware : Middleware public class DigestMiddleware : Middleware
{ {
private readonly bool computeDigests; private readonly List<string> digestKeys;
public DigestMiddleware(RequestDelegate next, bool computeDigests) : base(next) public DigestMiddleware(RequestDelegate next, List<string> digestKeys) : base(next)
{ {
this.computeDigests = computeDigests; this.digestKeys = digestKeys;
} }
#if !DEBUG private static async Task HandleResponseCompression(HttpContext context, MemoryStream responseBuffer)
private static readonly HashSet<string> exemptPathList = new()
{ {
"/login", const int minCompressionLen = 1000;
"/eula", if (responseBuffer.Length > minCompressionLen &&
"/announce",
"/status",
"/farc_hashes",
"/t_conf",
"/network_settings.nws",
"/ChallengeConfig.xml",
};
#endif
public override async Task InvokeAsync(HttpContext context)
{
// Client digest check.
if (!context.Request.Cookies.TryGetValue("MM_AUTH", out string? authCookie)) authCookie = string.Empty;
string digestPath = context.Request.Path;
#if !DEBUG
const string url = "/LITTLEBIGPLANETPS3_XML";
string strippedPath = digestPath.Contains(url) ? digestPath[url.Length..] : "";
#endif
byte[] bodyBytes = await context.Request.BodyReader.ReadAllAsync();
bool usedAlternateDigestKey = false;
if (this.computeDigests && digestPath.StartsWith("/LITTLEBIGPLANETPS3_XML"))
{
// The game sets X-Digest-B on a resource upload instead of X-Digest-A
string digestHeaderKey = "X-Digest-A";
bool excludeBodyFromDigest = false;
if (digestPath.Contains("/upload/"))
{
digestHeaderKey = "X-Digest-B";
excludeBodyFromDigest = true;
}
string clientRequestDigest = CryptoHelper.ComputeDigest(digestPath,
authCookie,
bodyBytes,
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey,
excludeBodyFromDigest);
// Check the digest we've just calculated against the digest header if the game set the header. They should match.
if (context.Request.Headers.TryGetValue(digestHeaderKey, out StringValues sentDigest))
{
if (clientRequestDigest != sentDigest)
{
// If we got here, the normal ServerDigestKey failed to validate. Lets try again with the alternate digest key.
usedAlternateDigestKey = true;
clientRequestDigest = CryptoHelper.ComputeDigest(digestPath,
authCookie,
bodyBytes,
ServerConfiguration.Instance.DigestKey.AlternateDigestKey,
excludeBodyFromDigest);
if (clientRequestDigest != sentDigest)
{
#if DEBUG
Console.WriteLine("Digest failed");
Console.WriteLine("digestKey: " + ServerConfiguration.Instance.DigestKey.PrimaryDigestKey);
Console.WriteLine("altDigestKey: " + ServerConfiguration.Instance.DigestKey.AlternateDigestKey);
Console.WriteLine("computed digest: " + clientRequestDigest);
#endif
// We still failed to validate. Abort the request.
context.Response.StatusCode = 403;
return;
}
}
}
#if !DEBUG
// The game doesn't start sending digests until after the announcement so if it's not one of those requests
// and it doesn't include a digest we need to reject the request
else if (!exemptPathList.Contains(strippedPath))
{
context.Response.StatusCode = 403;
return;
}
#endif
context.Response.Headers.Append("X-Digest-B", clientRequestDigest);
context.Request.Body.Position = 0;
}
// This does the same as above, but for the response stream.
await using MemoryStream responseBuffer = new();
Stream oldResponseStream = context.Response.Body;
context.Response.Body = responseBuffer;
await this.next(context); // Handle the request so we can get the server digest hash
responseBuffer.Position = 0;
if (responseBuffer.Length > 1000 &&
context.Request.Headers.AcceptEncoding.Contains("deflate") && context.Request.Headers.AcceptEncoding.Contains("deflate") &&
(context.Response.ContentType ?? string.Empty).Contains("text/xml")) (context.Response.ContentType ?? string.Empty).Contains("text/xml"))
{ {
@ -130,30 +39,95 @@ public class DigestMiddleware : Middleware
} }
else else
{ {
string headerName = !context.Response.Headers.ContentLength.HasValue string headerName = !context.Response.Headers.ContentLength.HasValue ? "Content-Length" : "X-Original-Content-Length";
? "Content-Length"
: "X-Original-Content-Length";
context.Response.Headers.Append(headerName, responseBuffer.Length.ToString()); context.Response.Headers.Append(headerName, responseBuffer.Length.ToString());
} }
}
// Compute the server digest hash. public override async Task InvokeAsync(HttpContext context)
if (this.computeDigests)
{ {
// If no digest keys are supplied, then we can't do anything
if (this.digestKeys.Count == 0)
{
await this.next(context);
return;
}
UseDigestAttribute? digestAttribute = context.GetEndpoint()?.Metadata.GetMetadata<UseDigestAttribute>();
if (digestAttribute == null)
{
await this.next(context);
return;
}
if (!context.Request.Cookies.TryGetValue("MM_AUTH", out string? authCookie)) authCookie = string.Empty;
string digestPath = context.Request.Path;
byte[] bodyBytes = await context.Request.BodyReader.ReadAllAsync();
if ((!context.Request.Headers.TryGetValue(digestAttribute.DigestHeaderName, out StringValues digestHeaders) ||
digestHeaders.Count != 1) && digestAttribute.EnforceDigest)
{
context.Response.StatusCode = 403;
return;
}
string? clientDigest = digestHeaders.FirstOrDefault() ?? null;
string? matchingDigestKey = null;
string? calculatedRequestDigest = null;
if (clientDigest != null)
{
foreach (string digestKey in this.digestKeys)
{
string calculatedDigest = CalculateDigest(digestKey, bodyBytes);
if (calculatedDigest != clientDigest) continue;
matchingDigestKey = digestKey;
calculatedRequestDigest = calculatedDigest;
}
}
matchingDigestKey ??= this.digestKeys.First();
switch (calculatedRequestDigest)
{
case null when digestAttribute.EnforceDigest:
context.Response.StatusCode = 403;
return;
case null:
calculatedRequestDigest = CalculateDigest(matchingDigestKey, bodyBytes);
break;
}
context.Response.Headers.Append("X-Digest-B", calculatedRequestDigest);
// Let endpoint generate response so we can calculate the digest for it
Stream originalBody = context.Response.Body;
await using MemoryStream responseBuffer = new();
context.Response.Body = responseBuffer;
await this.next(context);
await HandleResponseCompression(context, responseBuffer);
string responseDigest = CalculateDigest(matchingDigestKey, responseBuffer.ToArray());
context.Response.Headers.Append("X-Digest-A", responseDigest);
responseBuffer.Position = 0; responseBuffer.Position = 0;
await responseBuffer.CopyToAsync(originalBody);
context.Response.Body = originalBody;
return;
string digestKey = usedAlternateDigestKey string CalculateDigest(string digestKey, byte[] data) =>
? ServerConfiguration.Instance.DigestKey.AlternateDigestKey CryptoHelper.ComputeDigest(digestPath,
: ServerConfiguration.Instance.DigestKey.PrimaryDigestKey; authCookie,
data,
// Compute the digest for the response. digestKey,
string serverDigest = digestAttribute.ExcludeBodyFromDigest);
CryptoHelper.ComputeDigest(context.Request.Path, authCookie, responseBuffer.ToArray(), digestKey);
context.Response.Headers.Append("X-Digest-A", serverDigest);
} }
// Copy the buffered response to the actual response stream.
responseBuffer.Position = 0;
await responseBuffer.CopyToAsync(oldResponseStream);
context.Response.Body = oldResponseStream;
}
} }

View file

@ -84,8 +84,6 @@ public class GameServerStartup
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env) public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
bool computeDigests = true;
if (string.IsNullOrEmpty(ServerConfiguration.Instance.DigestKey.PrimaryDigestKey)) if (string.IsNullOrEmpty(ServerConfiguration.Instance.DigestKey.PrimaryDigestKey))
{ {
Logger.Warn Logger.Warn
@ -94,7 +92,6 @@ public class GameServerStartup
"To increase security, it is recommended that you find and set this variable.", "To increase security, it is recommended that you find and set this variable.",
LogArea.Startup LogArea.Startup
); );
computeDigests = false;
} }
#if DEBUG #if DEBUG
@ -105,11 +102,17 @@ public class GameServerStartup
app.UseMiddleware<RequestLogMiddleware>(); app.UseMiddleware<RequestLogMiddleware>();
app.UseMiddleware<RateLimitMiddleware>(); app.UseMiddleware<RateLimitMiddleware>();
app.UseMiddleware<DigestMiddleware>(computeDigests);
app.UseMiddleware<SetLastContactMiddleware>(); app.UseMiddleware<SetLastContactMiddleware>();
app.UseRouting(); app.UseRouting();
List<string> digestKeys =
[
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey,
ServerConfiguration.Instance.DigestKey.AlternateDigestKey,
];
app.UseMiddleware<DigestMiddleware>(digestKeys);
app.UseAuthorization(); app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers()); app.UseEndpoints(endpoints => endpoints.MapControllers());

View file

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
[ApiController]
[Authorize]
[UseDigest]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class GameController : ControllerBase;

View file

@ -0,0 +1,11 @@
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class UseDigestAttribute : Attribute
{
public bool EnforceDigest { get; set; } = true;
public string DigestHeaderName { get; set; } = "X-Digest-A";
public bool ExcludeBodyFromDigest { get; set; }
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares; using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using Xunit; using Xunit;
@ -14,25 +14,48 @@ namespace ProjectLighthouse.Tests.GameApiTests.Unit.Middlewares;
[Trait("Category", "Unit")] [Trait("Category", "Unit")]
public class DigestMiddlewareTests public class DigestMiddlewareTests
{ {
private static DefaultHttpContext GetHttpContext
[Fact] (Stream body, string path, string cookie, Dictionary<string, StringValues>? extraHeaders = null, UseDigestAttribute? digestAttribute = null)
public async Task DigestMiddleware_ShouldNotComputeDigests_WhenDigestsDisabled()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = new()
{ {
Request = Request =
{ {
Body = new MemoryStream(), Body = body,
Path = "/LITTLEBIGPLANETPS3_XML/notification", Path = path,
Headers = { KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"), }, Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", cookie),
},
}, },
}; };
if (extraHeaders != null)
{
foreach ((string key, StringValues value) in extraHeaders)
{
context.Request.Headers.Append(key, value);
}
}
if (digestAttribute != null)
{
context.SetEndpoint(new Endpoint(null, new EndpointMetadataCollection(digestAttribute), null));
}
return context;
}
[Fact]
public async Task DigestMiddleware_ShouldNotComputeDigests_WithoutDigestAttribute()
{
DefaultHttpContext context = GetHttpContext(new MemoryStream(), "/LITTLEBIGPLANETPS3_XML/notification", "MM_AUTH=unittest");
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, false); }, []);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -46,33 +69,24 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldReject_WhenDigestHeaderIsMissing() public async Task DigestMiddleware_ShouldReject_WhenDigestHeaderIsMissing()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream(),
{ "/LITTLEBIGPLANETPS3_XML/notification",
Request = "MM_AUTH=unittest",
{ null,
Body = new MemoryStream(), new UseDigestAttribute());
Path = "/LITTLEBIGPLANETPS3_XML/notification",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
},
},
};
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
const int expectedCode = 403; const int expectedCode = 403;
Assert.True(expectedCode == context.Response.StatusCode, Assert.Equal(expectedCode, context.Response.StatusCode);
"The digest middleware accepted the request when it shouldn't have (are you running this test in Debug mode?)");
Assert.False(context.Response.Headers.TryGetValue("X-Digest-A", out _)); Assert.False(context.Response.Headers.TryGetValue("X-Digest-A", out _));
Assert.False(context.Response.Headers.TryGetValue("X-Digest-B", out _)); Assert.False(context.Response.Headers.TryGetValue("X-Digest-B", out _));
} }
@ -80,28 +94,23 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldReject_WhenRequestDigestInvalid() public async Task DigestMiddleware_ShouldReject_WhenRequestDigestInvalid()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream(),
"/LITTLEBIGPLANETPS3_XML/notification",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream(), "X-Digest-A", "invalid_digest"
Path = "/LITTLEBIGPLANETPS3_XML/notification",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
KeyValuePair.Create<string, StringValues>("X-Digest-A", "invalid_digest"),
}, },
}, },
}; new UseDigestAttribute());
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
ServerConfiguration.Instance.DigestKey.AlternateDigestKey = "test";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -115,28 +124,24 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldUseAlternateDigest_WhenPrimaryDigestInvalid() public async Task DigestMiddleware_ShouldUseAlternateDigest_WhenPrimaryDigestInvalid()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream(),
"/LITTLEBIGPLANETPS3_XML/notification",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream(), "X-Digest-A", "df619790a2579a077eae4a6b6864966ff4768723"
Path = "/LITTLEBIGPLANETPS3_XML/notification",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
KeyValuePair.Create<string, StringValues>("X-Digest-A", "df619790a2579a077eae4a6b6864966ff4768723"),
}, },
}, },
}; new UseDigestAttribute());
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "test";
ServerConfiguration.Instance.DigestKey.AlternateDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["test", "bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -152,28 +157,24 @@ public class DigestMiddlewareTests
} }
[Fact] [Fact]
public async Task DigestMiddleware_ShouldNotReject_WhenRequestingAnnounce() public async Task DigestMiddleware_ShouldNotReject_WhenNotEnforcingDigest()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream(),
"/LITTLEBIGPLANETPS3_XML/announce",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>(),
new UseDigestAttribute
{ {
Request = EnforceDigest = false,
{ });
Body = new MemoryStream(),
Path = "/LITTLEBIGPLANETPS3_XML/announce",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
},
},
};
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -191,26 +192,24 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldCalculate_WhenAuthCookieEmpty() public async Task DigestMiddleware_ShouldCalculate_WhenAuthCookieEmpty()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream(),
"/LITTLEBIGPLANETPS3_XML/notification",
"",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream(), "X-Digest-A", "0a06d25662c2d3bab2a767c0c504898df2385e62"
Path = "/LITTLEBIGPLANETPS3_XML/notification",
Headers =
{
KeyValuePair.Create<string, StringValues>("X-Digest-A", "0a06d25662c2d3bab2a767c0c504898df2385e62"),
}, },
}, },
}; new UseDigestAttribute());
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -228,27 +227,24 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldComputeDigestsWithNoBody_WhenDigestsEnabled() public async Task DigestMiddleware_ShouldComputeDigestsWithNoBody_WhenDigestsEnabled()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream(),
"/LITTLEBIGPLANETPS3_XML/notification",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream(), "X-Digest-A", "df619790a2579a077eae4a6b6864966ff4768723"
Path = "/LITTLEBIGPLANETPS3_XML/notification",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
KeyValuePair.Create<string, StringValues>("X-Digest-A", "df619790a2579a077eae4a6b6864966ff4768723"),
}, },
}, },
}; new UseDigestAttribute());
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -266,27 +262,24 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldComputeDigestsWithBody_WhenDigestsEnabled_AndNoResponseBody() public async Task DigestMiddleware_ShouldComputeDigestsWithBody_WhenDigestsEnabled_AndNoResponseBody()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream("digest test"u8.ToArray()),
"/LITTLEBIGPLANETPS3_XML/filter",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream("digest test"u8.ToArray()), "X-Digest-A", "3105059f9283773f7982a4d79455bcc97c330f10"
Path = "/LITTLEBIGPLANETPS3_XML/filter",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
KeyValuePair.Create<string, StringValues>("X-Digest-A", "3105059f9283773f7982a4d79455bcc97c330f10"),
}, },
}, },
}; new UseDigestAttribute());
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -304,27 +297,24 @@ public class DigestMiddlewareTests
[Fact] [Fact]
public async Task DigestMiddleware_ShouldComputeDigestsWithBody_WhenDigestsEnabled_AndResponseBody() public async Task DigestMiddleware_ShouldComputeDigestsWithBody_WhenDigestsEnabled_AndResponseBody()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream("digest test"u8.ToArray()),
"/LITTLEBIGPLANETPS3_XML/filter",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream("digest test"u8.ToArray()), "X-Digest-A", "3105059f9283773f7982a4d79455bcc97c330f10"
Path = "/LITTLEBIGPLANETPS3_XML/filter",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
KeyValuePair.Create<string, StringValues>("X-Digest-A", "3105059f9283773f7982a4d79455bcc97c330f10"),
}, },
}, },
}; new UseDigestAttribute());
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh";
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync("digest test"); httpContext.Response.WriteAsync("digest test");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -340,29 +330,31 @@ public class DigestMiddlewareTests
} }
[Fact] [Fact]
public async Task DigestMiddleware_ShouldComputeDigestsWithBody_WhenUploading() public async Task DigestMiddleware_ShouldExcludeBody_WithAttributeSetting()
{ {
DefaultHttpContext context = new() DefaultHttpContext context = GetHttpContext(new MemoryStream("digest test"u8.ToArray()),
"/LITTLEBIGPLANETPS3_XML/upload/unittesthash",
"MM_AUTH=unittest",
new Dictionary<string, StringValues>
{ {
Request =
{ {
Body = new MemoryStream("digest test"u8.ToArray()), "X-Digest-B", "2e54cd2bc69ff8c1ff85dd3b4f62e0a0e27d9e23"
Path = "/LITTLEBIGPLANETPS3_XML/upload/unittesthash",
Headers =
{
KeyValuePair.Create<string, StringValues>("Cookie", "MM_AUTH=unittest"),
KeyValuePair.Create<string, StringValues>("X-Digest-B", "2e54cd2bc69ff8c1ff85dd3b4f62e0a0e27d9e23"),
}, },
}, },
}; new UseDigestAttribute
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh"; {
DigestHeaderName = "X-Digest-B",
ExcludeBodyFromDigest = true,
});
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
httpContext.Response.WriteAsync(""); httpContext.Response.WriteAsync("");
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);
@ -398,7 +390,8 @@ public class DigestMiddlewareTests
}, },
}, },
}; };
ServerConfiguration.Instance.DigestKey.PrimaryDigestKey = "bruh"; context.SetEndpoint(new Endpoint(null, new EndpointMetadataCollection(new UseDigestAttribute()), null));
DigestMiddleware middleware = new(httpContext => DigestMiddleware middleware = new(httpContext =>
{ {
httpContext.Response.StatusCode = 200; httpContext.Response.StatusCode = 200;
@ -406,7 +399,7 @@ public class DigestMiddlewareTests
httpContext.Response.Headers.ContentType = "text/xml"; httpContext.Response.Headers.ContentType = "text/xml";
return Task.CompletedTask; return Task.CompletedTask;
}, },
true); ["bruh",]);
await middleware.InvokeAsync(context); await middleware.InvokeAsync(context);