Program.cs und appsettings.json bearbeitet. Abschnitt Config aus appsettings.json entfernt.
This commit is contained in:
parent
0ef9d3c49e
commit
1664b5739e
@ -14,5 +14,6 @@
|
||||
public static readonly string PossibleSecurityBreach = nameof(PossibleSecurityBreach);
|
||||
public static readonly string WrongEnvelopeReceiverId = nameof(WrongEnvelopeReceiverId);
|
||||
public static readonly string EnvelopeOrReceiverNonexists = nameof(EnvelopeOrReceiverNonexists);
|
||||
public static readonly string Default = nameof(Default);
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ namespace EnvelopeGenerator.Web.Controllers.Test
|
||||
{
|
||||
try
|
||||
{
|
||||
var passwordFromConfig = _config["Config:AdminPassword"];
|
||||
var passwordFromConfig = _config["AdminPassword"];
|
||||
|
||||
if (passwordFromConfig == null)
|
||||
{
|
||||
|
||||
@ -18,7 +18,6 @@ using System.Text.Encodings.Web;
|
||||
using Ganss.Xss;
|
||||
using Microsoft.Extensions.Options;
|
||||
using DigitalData.EmailProfilerDispatcher.Application;
|
||||
using DigitalData.UserManager.Application;
|
||||
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Info("Logging initialized!");
|
||||
@ -72,7 +71,7 @@ try
|
||||
}
|
||||
|
||||
//AddEF Core dbcontext
|
||||
var connStr = config["Config:ConnectionString"];
|
||||
var connStr = config.GetConnectionString(Key.Default) ?? throw new InvalidOperationException("There is no default connection string in appsettings.json.");
|
||||
builder.Services.AddDbContext<EGDbContext>(options => options.UseSqlServer(connStr));
|
||||
|
||||
//Inject CRUD Service and repositoriesad
|
||||
@ -151,7 +150,7 @@ try
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton(_ => config.GetSection("ContactLink").Get<ContactLink>() ?? new ContactLink());
|
||||
builder.Services.AddSingleton(config.GetSection("ContactLink").Get<ContactLink>() ?? new());
|
||||
|
||||
builder.Services.AddCookieConsentSettings();
|
||||
|
||||
@ -167,7 +166,7 @@ try
|
||||
});
|
||||
|
||||
// Register the FlagIconCssClass instance as a singleton
|
||||
builder.Services.Configure<Cultures>(builder.Configuration.GetSection("Cultures"));
|
||||
builder.Services.Configure<Cultures>(config.GetSection("Cultures"));
|
||||
builder.Services.AddSingleton(sp => sp.GetRequiredService<IOptions<Cultures>>().Value);
|
||||
|
||||
// Register mail services
|
||||
@ -185,11 +184,18 @@ try
|
||||
}
|
||||
|
||||
//Content-Security-Policy
|
||||
if (config.GetValue<bool>("TestCSP") || !app.Environment.IsDevelopment())
|
||||
if (config.GetValue<bool>("UseCSPInDev") || !app.Environment.IsDevelopment())
|
||||
{
|
||||
var csp_list = config.GetSection("Content-Security-Policy").Get<string[]>();
|
||||
if (csp_list is null)
|
||||
logger.Warn("There is no Content-Security-Policy");
|
||||
else
|
||||
{
|
||||
var csp = string.Join("; ", csp_list?.Where(st => st is not null) ?? Array.Empty<string>());
|
||||
logger.Info($"Content-Security-Policy {csp}");
|
||||
if (csp_list is not null)
|
||||
app.UseCSPMiddleware($"{string.Join("; ", csp_list)};");
|
||||
app.UseCSPMiddleware(csp);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.GetValue<bool>("EnableSwagger"))
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using DigitalData.Modules.Database;
|
||||
using DigitalData.Modules.Logging;
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.Common;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Services
|
||||
@ -52,11 +53,11 @@ namespace EnvelopeGenerator.Web.Services
|
||||
|
||||
public DatabaseService(ILogger<DatabaseService> logger, IConfiguration config)
|
||||
{
|
||||
LogConfig logConfig = new LogConfig(LogConfig.PathType.CustomPath, config["Config:LogPath"], null, "Digital Data", "ECM.EnvelopeGenerator.Web");
|
||||
LogConfig logConfig = new LogConfig(LogConfig.PathType.CustomPath, config["NLog:variables:logDirectory"], null, "Digital Data", "ECM.EnvelopeGenerator.Web");
|
||||
_logger = logger;
|
||||
|
||||
_logger.LogInformation("Establishing MSSQL Database connection..");
|
||||
MSSQL = new MSSQLServer(logConfig, config["Config:ConnectionString"]);
|
||||
MSSQL = new MSSQLServer(logConfig, config.GetConnectionString(Key.Default));
|
||||
|
||||
if (MSSQL.DBInitialized == true)
|
||||
{
|
||||
|
||||
@ -10,20 +10,16 @@
|
||||
"Microsoft.AspNetCore.Hosting.Diagnostics": "Warning"
|
||||
}
|
||||
},
|
||||
"Config": {
|
||||
"ConnectionString": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;",
|
||||
"LogPath": "E:\\EnvelopeGenerator\\Logs",
|
||||
"LogDebug": true,
|
||||
"LogJson": true,
|
||||
"AdminPassword": "dd"
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||
},
|
||||
"AdminPassword": "dd",
|
||||
"PSPDFKitLicenseKey": null,
|
||||
/* The first format parameter {0} will be replaced by the nonce value. */
|
||||
"TestCSP": false,
|
||||
"Content-Security-Policy": [
|
||||
"UseCSPInDev": false,
|
||||
"Content-Security-Policy": [ // The first format parameter {0} will be replaced by the nonce value.
|
||||
"default-src 'self'",
|
||||
"script-src 'self' 'nonce-{0}' 'unsafe-inline' 'unsafe-eval' blob: data:",
|
||||
"style-src 'self' 'unsafe-inline'",
|
||||
"script-src 'self' 'nonce-{0}' blob: data:",
|
||||
"style-src 'self'",
|
||||
"img-src 'self' data: https: blob:",
|
||||
"font-src 'self'",
|
||||
"connect-src 'self' http://localhost:* https://localhost:* ws://localhost:* wss://localhost:* blob:",
|
||||
@ -32,24 +28,27 @@
|
||||
"object-src 'self'",
|
||||
"worker-src 'self' blob: data:"
|
||||
],
|
||||
"AdminPassword": "dd",
|
||||
"AllowedOrigins": [ "https://localhost:7202", "https://digitale.unterschrift.wisag.de/" ],
|
||||
"NLog": {
|
||||
"throwConfigExceptions": true,
|
||||
"variables": {
|
||||
"logDirectory": "E:\\EnvelopeGenerator\\Logs",
|
||||
"logFileNamePrefix": "${shortdate}-ECM.EnvelopeGenerator.Web"
|
||||
},
|
||||
"targets": {
|
||||
"infoLogs": {
|
||||
"type": "File",
|
||||
"fileName": "E:\\EnvelopeGenerator\\Logs\\${shortdate}-ECM.EnvelopeGenerator.Web-Info.log",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"errorLogs": {
|
||||
"type": "File",
|
||||
"fileName": "E:\\EnvelopeGenerator\\Logs\\${shortdate}-ECM.EnvelopeGenerator.Web-Error.log",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"criticalLogs": {
|
||||
"type": "File",
|
||||
"fileName": "E:\\EnvelopeGenerator\\Logs\\${shortdate}-ECM.EnvelopeGenerator.Web-Critical.log",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||
"maxArchiveDays": 30
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user