Files
PetriePanel/WebAPI/Data/AppSettings.cs
littlefoot 320d939c76 Authentication finally moved to the dotnet way in webapi, ready to be added to to deal with users and such
Introspection access point properly uses basic auth of client id and secret to access
2021-10-14 20:54:58 -04:00

33 lines
1.3 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace WebAPI.Data
{
public static class AppSettings
{
public static string PterodactylAPIKey { get; private set; }
public static string PterodactylPanelURL { get; private set; }
public static string OIDCIntrospectionEndpoint { get; private set; }
public static string OIDCClientId { get; private set; }
public static string OIDCClientSecret { get; set; }
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));
}
}
}
}
}