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