diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml index e185814e..97278a6a 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml @@ -14,8 +14,22 @@ else {

You have @Model.AuthenticationAttempts.Count authentication attempts pending.

+ @if (Model.IpAddress != null) + { +

This device's IP address is @(Model.IpAddress.ToString()). If this matches with an authentication attempt below, then it's safe to assume the authentication attempt came from the same network as this device.

+ } + + + + - + } @@ -25,11 +39,23 @@ else

A @authAttempt.Platform authentication request was logged at @timestamp.ToString("MM/dd/yyyy @ h:mm tt") UTC from the IP address @authAttempt.IPAddress.

+ + + - + - +
diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs index 13a1f5eb..6ca2576a 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs @@ -1,5 +1,7 @@ +#nullable enable using System.Collections.Generic; using System.Linq; +using System.Net; using System.Threading.Tasks; using LBPUnion.ProjectLighthouse.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types; @@ -13,12 +15,17 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth { public List AuthenticationAttempts; + + public IPAddress? IpAddress; public AuthenticationPage(Database database) : base(database) {} public async Task OnGet() { if (!ServerSettings.Instance.UseExternalAuth) return this.NotFound(); + if (this.User == null) return this.StatusCode(403, ""); + + this.IpAddress = this.HttpContext.Connection.RemoteIpAddress; this.AuthenticationAttempts = this.Database.AuthenticationAttempts.Include (a => a.GameToken)