Add configurations and update packages

This commit is contained in:
2021-07-15 22:28:26 +02:00
parent 84b5e44a83
commit c84077ef58
23 changed files with 451 additions and 102 deletions

View File

@@ -0,0 +1,32 @@
using GerstITS.System.Configurations;
using GerstITS.Web.Api.Builder;
using Microsoft.Extensions.Configuration;
namespace BakeTronic.Web.Api.Configurations
{
internal sealed class CorsPolicyConfiguration : ICorsPolicy, GerstITS.System.Configurations.IConfiguration
{
#region Constructors
public CorsPolicyConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration)
{
var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}";
AllowCredentials = configuration.GetValue<bool>($"{prefix}:{nameof(AllowCredentials)}", false);
AllowedOrigins = configuration.GetSection($"{prefix}:{nameof(AllowedOrigins)}").Get<string[]>() ?? new string[0];
AllowedHeaders = configuration.GetSection($"{prefix}:{nameof(AllowedHeaders)}").Get<string[]>() ?? new string[0];
AllowedMethods = configuration.GetSection($"{prefix}:{nameof(AllowedMethods)}").Get<string[]>() ?? new string[0];
}
#endregion
#region ICorsPolicy
public bool AllowCredentials { get; }
public string[] AllowedOrigins { get; set; }
public string[] AllowedHeaders { get; set; }
public string[] AllowedMethods { get; set; }
#endregion
}
}