This commit is contained in:
2021-10-13 18:16:47 -04:00
parent d0ad783cfd
commit 2552ad4d87
3 changed files with 45 additions and 0 deletions

28
Web/Data/AppSettings.cs Normal file
View File

@@ -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<string>(propertyInfo.Name));
}
else if (propertyInfo.PropertyType == typeof(int))
{
propertyInfo.SetValue(null, configuration.GetValue<int>(propertyInfo.Name));
}
else if (propertyInfo.PropertyType == typeof(double))
{
propertyInfo.SetValue(null, configuration.GetValue<double>(propertyInfo.Name));
}
}
}
}
}

View File

@@ -29,6 +29,17 @@ namespace Web
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddSingleton<WeatherForecastService>();
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 =>
{

View File

@@ -4,4 +4,9 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.11" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.13.1" />
</ItemGroup>
</Project>