Redesign authentication page

This commit is contained in:
jvyden 2021-12-13 14:53:42 -05:00
parent e0156400b8
commit d609291d8f
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 36 additions and 3 deletions

View file

@ -14,8 +14,22 @@
else else
{ {
<p>You have @Model.AuthenticationAttempts.Count authentication attempts pending.</p> <p>You have @Model.AuthenticationAttempts.Count authentication attempts pending.</p>
@if (Model.IpAddress != null)
{
<p>This device's IP address is <b>@(Model.IpAddress.ToString())</b>. 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.</p>
}
<a href="/authentication/autoApprovals">
<button class="ui small blue button">
<i class="cog icon"></i>
<span>Manage automatically approved IP addresses</span>
</button>
</a>
<a href="/authentication/denyAll"> <a href="/authentication/denyAll">
<button class="ui small red button">Deny all</button> <button class="ui small red button">
<i class="x icon"></i>
<span>Deny all</span>
</button>
</a> </a>
} }
@ -25,11 +39,23 @@ else
<div class="ui red segment"> <div class="ui red segment">
<p>A <b>@authAttempt.Platform</b> authentication request was logged at <b>@timestamp.ToString("MM/dd/yyyy @ h:mm tt") UTC</b> from the IP address <b>@authAttempt.IPAddress</b>.</p> <p>A <b>@authAttempt.Platform</b> authentication request was logged at <b>@timestamp.ToString("MM/dd/yyyy @ h:mm tt") UTC</b> from the IP address <b>@authAttempt.IPAddress</b>.</p>
<div> <div>
<a href="/authentication/autoApprove/@authAttempt.AuthenticationAttemptId">
<button class="ui tiny green button">
<i class="check icon"></i>
<span>Automatically approve every time</span>
</button>
</a>
<a href="/authentication/approve/@authAttempt.AuthenticationAttemptId"> <a href="/authentication/approve/@authAttempt.AuthenticationAttemptId">
<button class="ui tiny green button">Approve</button> <button class="ui tiny yellow button">
<i class="check icon"></i>
<span>Approve this time</span>
</button>
</a> </a>
<a href="/authentication/deny/@authAttempt.AuthenticationAttemptId"> <a href="/authentication/deny/@authAttempt.AuthenticationAttemptId">
<button class="ui tiny red button">Deny</button> <button class="ui tiny red button">
<i class="x icon"></i>
<span>Deny</span>
</button>
</a> </a>
</div> </div>
</div> </div>

View file

@ -1,5 +1,7 @@
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Pages.Layouts; using LBPUnion.ProjectLighthouse.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types;
@ -13,12 +15,17 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
{ {
public List<AuthenticationAttempt> AuthenticationAttempts; public List<AuthenticationAttempt> AuthenticationAttempts;
public IPAddress? IpAddress;
public AuthenticationPage(Database database) : base(database) public AuthenticationPage(Database database) : base(database)
{} {}
public async Task<IActionResult> OnGet() public async Task<IActionResult> OnGet()
{ {
if (!ServerSettings.Instance.UseExternalAuth) return this.NotFound(); 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 this.AuthenticationAttempts = this.Database.AuthenticationAttempts.Include
(a => a.GameToken) (a => a.GameToken)