From c385ee0628a292f2bac6c1e372007897ffa7fd96 Mon Sep 17 00:00:00 2001 From: Henry Trumme Date: Sat, 10 May 2025 16:35:40 +0200 Subject: [PATCH] Save --- Docs/.$ER-Diagramm.drawio.bkp | 945 +++++++++++++++++ .../.idea/.idea.WatchLog/.idea/.gitignore | 13 + .../.idea.WatchLog/.idea/dataSources.xml | 15 + .../.idea/.idea.WatchLog/.idea/encodings.xml | 4 + .../.idea.WatchLog/.idea/indexLayout.xml | 8 + WatchLog/.idea/.idea.WatchLog/.idea/vcs.xml | 6 + WatchLog/.idea/config/applicationhost.config | 997 ++++++++++++++++++ .../Components/Pages/GlobalEntities.razor | 2 +- WatchLog/Data/Database/Global/Admin.cs | 2 +- WatchLog/Data/Database/Global/User.cs | 2 +- WatchLog/Program.cs | 27 + WatchLog/WatchLog.csproj | 1 + WatchLog/identifier.sqlite | 0 13 files changed, 2019 insertions(+), 3 deletions(-) create mode 100644 Docs/.$ER-Diagramm.drawio.bkp create mode 100644 WatchLog/.idea/.idea.WatchLog/.idea/.gitignore create mode 100644 WatchLog/.idea/.idea.WatchLog/.idea/dataSources.xml create mode 100644 WatchLog/.idea/.idea.WatchLog/.idea/encodings.xml create mode 100644 WatchLog/.idea/.idea.WatchLog/.idea/indexLayout.xml create mode 100644 WatchLog/.idea/.idea.WatchLog/.idea/vcs.xml create mode 100644 WatchLog/.idea/config/applicationhost.config create mode 100644 WatchLog/identifier.sqlite diff --git a/Docs/.$ER-Diagramm.drawio.bkp b/Docs/.$ER-Diagramm.drawio.bkp new file mode 100644 index 0000000..7144f0f --- /dev/null +++ b/Docs/.$ER-Diagramm.drawio.bkp @@ -0,0 +1,945 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WatchLog/.idea/.idea.WatchLog/.idea/.gitignore b/WatchLog/.idea/.idea.WatchLog/.idea/.gitignore new file mode 100644 index 0000000..9a048ec --- /dev/null +++ b/WatchLog/.idea/.idea.WatchLog/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/.idea.WatchLog.iml +/projectSettingsUpdater.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/WatchLog/.idea/.idea.WatchLog/.idea/dataSources.xml b/WatchLog/.idea/.idea.WatchLog/.idea/dataSources.xml new file mode 100644 index 0000000..67a4e5a --- /dev/null +++ b/WatchLog/.idea/.idea.WatchLog/.idea/dataSources.xml @@ -0,0 +1,15 @@ + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/Data/WatchLog.db + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/WatchLog/.idea/.idea.WatchLog/.idea/encodings.xml b/WatchLog/.idea/.idea.WatchLog/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/WatchLog/.idea/.idea.WatchLog/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/WatchLog/.idea/.idea.WatchLog/.idea/indexLayout.xml b/WatchLog/.idea/.idea.WatchLog/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/WatchLog/.idea/.idea.WatchLog/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/WatchLog/.idea/.idea.WatchLog/.idea/vcs.xml b/WatchLog/.idea/.idea.WatchLog/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/WatchLog/.idea/.idea.WatchLog/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WatchLog/.idea/config/applicationhost.config b/WatchLog/.idea/config/applicationhost.config new file mode 100644 index 0000000..09263d1 --- /dev/null +++ b/WatchLog/.idea/config/applicationhost.config @@ -0,0 +1,997 @@ + + + + + + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WatchLog/Components/Pages/GlobalEntities.razor b/WatchLog/Components/Pages/GlobalEntities.razor index c059e87..2064704 100644 --- a/WatchLog/Components/Pages/GlobalEntities.razor +++ b/WatchLog/Components/Pages/GlobalEntities.razor @@ -1,5 +1,5 @@ @rendermode InteractiveServer -@page "/" +@page "/GlobalEntities" @using Microsoft.EntityFrameworkCore @using WatchLog.Data @inject IDbContextFactory WatchLogDataContextFactory; diff --git a/WatchLog/Data/Database/Global/Admin.cs b/WatchLog/Data/Database/Global/Admin.cs index a0f5f7d..c64629d 100644 --- a/WatchLog/Data/Database/Global/Admin.cs +++ b/WatchLog/Data/Database/Global/Admin.cs @@ -12,6 +12,6 @@ namespace WatchLog.Data public required string Name { get; set; } [Required] - public required string Password { get; set; } // Important: Save as HASH + public required string PasswordHash { get; set; } // Important: Save as HASH } } \ No newline at end of file diff --git a/WatchLog/Data/Database/Global/User.cs b/WatchLog/Data/Database/Global/User.cs index e831dd1..cf73229 100644 --- a/WatchLog/Data/Database/Global/User.cs +++ b/WatchLog/Data/Database/Global/User.cs @@ -15,7 +15,7 @@ namespace WatchLog.Data public string? Email { get; set; } [Required] - public required string Password { get; set; } // Important: Save as HASH + public required string PasswordHash { get; set; } // Important: Save as HASH // --- Navigation Properties --- diff --git a/WatchLog/Program.cs b/WatchLog/Program.cs index 8243a97..55bc05b 100644 --- a/WatchLog/Program.cs +++ b/WatchLog/Program.cs @@ -2,6 +2,9 @@ using WatchLog.Components; using WatchLog.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Identity; namespace WatchLog { @@ -19,6 +22,27 @@ namespace WatchLog builder.Services.AddDbContextFactory(options => options.UseSqlite(connectionString)); + builder.Services.AddHttpContextAccessor(); + + builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) + .AddCookie(options => + { + options.Cookie.Name = "WatchLogAuthCookie"; + options.LoginPath = "/login"; + options.LogoutPath = "/logout"; + options.AccessDeniedPath = "/access-denied"; + options.ExpireTimeSpan = TimeSpan.FromDays(1); + options.SlidingExpiration = true; + }); + + builder.Services.AddAuthorization(options => + { + options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + }); + + builder.Services.AddScoped, PasswordHasher>(); + builder.Services.AddScoped, PasswordHasher>(); + var app = builder.Build(); // Configure the HTTP request pipeline. @@ -33,6 +57,9 @@ namespace WatchLog app.UseStaticFiles(); app.UseAntiforgery(); + + app.UseAuthentication(); + app.UseAuthorization(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); diff --git a/WatchLog/WatchLog.csproj b/WatchLog/WatchLog.csproj index 19d4dfa..14166e7 100644 --- a/WatchLog/WatchLog.csproj +++ b/WatchLog/WatchLog.csproj @@ -8,6 +8,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/WatchLog/identifier.sqlite b/WatchLog/identifier.sqlite new file mode 100644 index 0000000..e69de29