diff --git a/Web/Data/AppSettings.cs b/Web/Data/AppSettings.cs new file mode 100644 index 0000000..65fbb1c --- /dev/null +++ b/Web/Data/AppSettings.cs @@ -0,0 +1,28 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace Web.Data +{ + public static class AppSettings + { + public static void Init(IConfiguration configuration) + { + var fields = typeof(AppSettings).GetProperties(); + foreach (var propertyInfo in fields) + { + if (propertyInfo.PropertyType == typeof(string)) + { + propertyInfo.SetValue(null, configuration.GetValue(propertyInfo.Name)); + } + else if (propertyInfo.PropertyType == typeof(int)) + { + propertyInfo.SetValue(null, configuration.GetValue(propertyInfo.Name)); + } + else if (propertyInfo.PropertyType == typeof(double)) + { + propertyInfo.SetValue(null, configuration.GetValue(propertyInfo.Name)); + } + } + } + } +} \ No newline at end of file diff --git a/Web/Startup.cs b/Web/Startup.cs index dee8c73..b5f040d 100644 --- a/Web/Startup.cs +++ b/Web/Startup.cs @@ -29,6 +29,17 @@ namespace Web services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton(); + services.AddAuthentication(options => + { + options.DefaultScheme = "Cookies"; + options.DefaultChallengeScheme = "oidc"; + }) + .AddCookie("Cookies") + .AddOpenIdConnect(options => + { + options.Authority = "https://authentik.mattstop.com/application/o/petrie-panel/"; + options.ClientId = "85bcc426a47ac2c3575b6d590ec4f53db237e212"; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -49,6 +60,7 @@ namespace Web app.UseStaticFiles(); app.UseRouting(); + //app.UseAuthentication(); app.UseEndpoints(endpoints => { diff --git a/Web/Web.csproj b/Web/Web.csproj index f685184..65fc74a 100644 --- a/Web/Web.csproj +++ b/Web/Web.csproj @@ -4,4 +4,9 @@ net5.0 + + + + +