mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Implement checking for the Patchwork user agent (#1090)
* Implement checking for the Patchwork user agent, move logout into standalone method * Quick fixes (awesome name) * 403 user at login instead of logging out at /announce * Move configuration and revert logout changes * Rework parsing to check against GameVersion enum and game token GameVersion * Fix logic error oopsie * Fix Zaprit suggestions * Simplify patchwork game version test * Test patchwork user agent with regex instead * Fix Qodana warnings * Fix remaining Qodana warnings
This commit is contained in:
parent
df7ebf977a
commit
aeba706391
7 changed files with 85 additions and 4 deletions
|
@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Configuration;
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Tickets;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -212,6 +213,14 @@ public class LoginController : ControllerBase
|
|||
return this.Forbid();
|
||||
}
|
||||
|
||||
if (ServerConfiguration.Instance.Authentication.RequirePatchworkUserAgent)
|
||||
{
|
||||
if (!PatchworkHelper.IsValidPatchworkUserAgent(this.Request.Headers.UserAgent.ToString()))
|
||||
{
|
||||
return this.Forbid();
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
|
||||
|
||||
user.LastLogin = TimeHelper.TimestampMillis;
|
||||
|
|
|
@ -38,5 +38,4 @@ public class LogoutController : ControllerBase
|
|||
return this.Ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System.Text;
|
||||
using System.Text;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue