From bf759713bdd0862d583c199edcb30eb909a89b11 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 02:54:22 -0500 Subject: [PATCH] Add authentication page --- ProjectLighthouse.sln.DotSettings | 2 ++ .../ExternalAuth/AuthenticationPage.cshtml | 18 +++++++++++ .../ExternalAuth/AuthenticationPage.cshtml.cs | 30 +++++++++++++++++++ .../Pages/Layouts/BaseLayout.cshtml | 3 +- .../Types/AuthenticationAttempt.cs | 10 +++++++ ProjectLighthouse/Types/Platform.cs | 8 +++++ 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml create mode 100644 ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs create mode 100644 ProjectLighthouse/Types/AuthenticationAttempt.cs create mode 100644 ProjectLighthouse/Types/Platform.cs diff --git a/ProjectLighthouse.sln.DotSettings b/ProjectLighthouse.sln.DotSettings index 34c3a59a..54a00f4c 100644 --- a/ProjectLighthouse.sln.DotSettings +++ b/ProjectLighthouse.sln.DotSettings @@ -78,7 +78,9 @@ MM NAT NP + PS PSP + RPCS <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="aaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml new file mode 100644 index 00000000..f53deacf --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml @@ -0,0 +1,18 @@ +@page "/authentication" +@using LBPUnion.ProjectLighthouse.Types +@model LBPUnion.ProjectLighthouse.Pages.ExternalAuth.AuthenticationPage + +@{ + Layout = "Layouts/BaseLayout"; +} +
+@foreach (AuthenticationAttempt authAttempt in Model.AuthenticationAttempts) +{ +
+

A @authAttempt.Platform authentication request was logged at @authAttempt.Timestamp from the IP address @authAttempt.IPAddress.

+
+ Approve + Deny +
+
+} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs new file mode 100644 index 00000000..7af46f46 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; +using Microsoft.AspNetCore.Mvc; + +namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth +{ + public class AuthenticationPage : BaseLayout + { + public AuthenticationPage(Database database) : base(database) + {} + + public List AuthenticationAttempts = new() + { + new AuthenticationAttempt + { + Platform = Platform.RPCS3, + Timestamp = TimestampHelper.Timestamp, + IPAddress = "127.0.0.1", + }, + }; + + public async Task OnGet() + { + return this.Page(); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index bc352fba..23384f3a 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -12,7 +12,8 @@ } else { - Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout")); + Model.NavigationItems.Add(new PageNavigationItem("Authentication", "/authentication")); + Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout")); // should always be last } } diff --git a/ProjectLighthouse/Types/AuthenticationAttempt.cs b/ProjectLighthouse/Types/AuthenticationAttempt.cs new file mode 100644 index 00000000..131ef50b --- /dev/null +++ b/ProjectLighthouse/Types/AuthenticationAttempt.cs @@ -0,0 +1,10 @@ +namespace LBPUnion.ProjectLighthouse.Types +{ + public class AuthenticationAttempt + { + public long Timestamp; + public Platform Platform; + public string IPAddress; + public GameToken GameToken; + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Types/Platform.cs b/ProjectLighthouse/Types/Platform.cs new file mode 100644 index 00000000..d43c7085 --- /dev/null +++ b/ProjectLighthouse/Types/Platform.cs @@ -0,0 +1,8 @@ +namespace LBPUnion.ProjectLighthouse.Types +{ + public enum Platform + { + PS3, + RPCS3, + } +} \ No newline at end of file