Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44df489406 | |||
| 1bb1b0d476 | |||
| 0ea31a33ae | |||
| 0bb5da3513 |
@@ -18,13 +18,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteCharms.Features" Version="1.134.0" />
|
<PackageReference Include="LiteCharms.Features" Version="1.135.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- UI -->
|
<!-- UI -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" />
|
<PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" />
|
||||||
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.134.0" />
|
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.135.0" />
|
||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<Using Include="Blazored.Toast.Services" />
|
<Using Include="Blazored.Toast.Services" />
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
<Using Include="Microsoft.AspNetCore.Components.Web" />
|
<Using Include="Microsoft.AspNetCore.Components.Web" />
|
||||||
<Using Include="Microsoft.AspNetCore.WebUtilities" />
|
<Using Include="Microsoft.AspNetCore.WebUtilities" />
|
||||||
<Using Include="Microsoft.AspNetCore.Components" />
|
<Using Include="Microsoft.AspNetCore.Components" />
|
||||||
|
<Using Include="System.Security.Cryptography.X509Certificates" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+25
-83
@@ -1,109 +1,51 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Mediator;
|
|
||||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
|
||||||
using LiteCharms.Features.MidrandBooks.Payments;
|
|
||||||
using LiteCharms.Features.Postgres;
|
using LiteCharms.Features.Postgres;
|
||||||
|
using MidrandBookshop;
|
||||||
using MidrandBookshop.Components;
|
using MidrandBookshop.Components;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using static LiteCharms.Features.Extensions.Quartz;
|
using static LiteCharms.Features.Extensions.Quartz;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddAntiforgery();
|
|
||||||
|
|
||||||
builder.Services.AddRazorComponents()
|
|
||||||
.AddInteractiveServerComponents();
|
|
||||||
|
|
||||||
builder.AddMonitoring();
|
builder.AddMonitoring();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.RegisterServices(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
|
|
||||||
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
|
|
||||||
|
|
||||||
builder.Services.AddQuartzSchedulerClient(MidrandShopSchedulerName, builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddMediator();
|
|
||||||
builder.Services.AddEmailServices(builder.Configuration);
|
|
||||||
builder.Services.AddEmailServiceBus();
|
|
||||||
|
|
||||||
builder.Services.AddHttpClient();
|
|
||||||
builder.Services.AddScoped<CartService>();
|
|
||||||
builder.Services.AddShopServices(includeLocalStorage: true);
|
|
||||||
builder.Services.AddHashServices(builder.Configuration);
|
|
||||||
builder.Services.AddPayfastServices(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddDataProtectionDatabase(builder.Configuration);
|
|
||||||
builder.Services.AddMidrandShopDatabase(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddSecurityApiSdk(builder.Configuration);
|
|
||||||
builder.Services.AddLiteCharmsWebSecurity(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddMidrandShopPostgresHealthCheck();
|
|
||||||
builder.Services.AddMidrandShopQuartzHealthCheck();
|
|
||||||
builder.Services.AddHealthChecksSupport(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
|
||||||
{
|
|
||||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
|
||||||
options.KnownProxies.Clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.WebHost.ConfigureKestrel(options =>
|
|
||||||
{
|
|
||||||
var certBase64 = builder.Configuration["DataProtection:Certificate"];
|
|
||||||
var certPassword = builder.Configuration["DataProtection:Password"];
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(certBase64))
|
|
||||||
{
|
|
||||||
var rawBytes = Convert.FromBase64String(certBase64);
|
|
||||||
var kestrelCert = X509CertificateLoader.LoadPkcs12(rawBytes, certPassword);
|
|
||||||
|
|
||||||
options.ListenAnyIP(8443, listenOptions =>
|
|
||||||
{
|
|
||||||
listenOptions.UseHttps(kestrelCert);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
options.ListenAnyIP(8080);
|
|
||||||
});
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.UseForwardedHeaders();
|
|
||||||
app.UseCookiePolicy();
|
|
||||||
|
|
||||||
using var security = app.Services.CreateScope();
|
|
||||||
{
|
|
||||||
var dataProtectionContext = security.ServiceProvider.GetRequiredService<DataProtectionDbContext>();
|
|
||||||
|
|
||||||
await dataProtectionContext.Database.MigrateAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.AddSecurityEndpoints();
|
|
||||||
|
|
||||||
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
|
|
||||||
var scheduler = await schedulerFactory.GetScheduler(MidrandShopSchedulerName);
|
|
||||||
|
|
||||||
if (!scheduler!.IsStarted)
|
|
||||||
await scheduler.Start();
|
|
||||||
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseForwardedHeaders();
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
||||||
app.UseHealthChecks("/health", new HealthCheckOptions
|
app.UseHealthChecks("/health", new HealthCheckOptions
|
||||||
{
|
{
|
||||||
ResponseWriter = HealthChecks.UI.Client.UIResponseWriter.WriteHealthCheckUIResponse
|
ResponseWriter = HealthChecks.UI.Client.UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
app.UseAntiforgery();
|
|
||||||
|
|
||||||
app.MapStaticAssets();
|
app.MapStaticAssets();
|
||||||
|
app.UseCookiePolicy();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.UseAntiforgery();
|
||||||
|
app.AddSecurityEndpoints();
|
||||||
|
|
||||||
|
using (var security = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var dataProtectionContext = security.ServiceProvider.GetRequiredService<DataProtectionDbContext>();
|
||||||
|
|
||||||
|
await dataProtectionContext.Database.MigrateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
|
||||||
|
var scheduler = await schedulerFactory.GetScheduler(MidrandShopSchedulerName);
|
||||||
|
|
||||||
|
if (!scheduler!.IsStarted) await scheduler.Start();
|
||||||
|
|
||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using LiteCharms.Features.Mediator;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Payments;
|
||||||
|
using LiteCharms.Features.Extensions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||||
|
using static LiteCharms.Features.Extensions.Quartz;
|
||||||
|
|
||||||
|
namespace MidrandBookshop;
|
||||||
|
|
||||||
|
public static class Setup
|
||||||
|
{
|
||||||
|
public static IServiceCollection RegisterServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddAntiforgery();
|
||||||
|
|
||||||
|
services.AddRazorComponents()
|
||||||
|
.AddInteractiveServerComponents();
|
||||||
|
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
|
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
|
||||||
|
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
|
||||||
|
|
||||||
|
services.AddQuartzSchedulerClient(MidrandShopSchedulerName, configuration);
|
||||||
|
|
||||||
|
services.AddMediator();
|
||||||
|
services.AddEmailServices(configuration);
|
||||||
|
services.AddEmailServiceBus();
|
||||||
|
|
||||||
|
services.AddHttpClient();
|
||||||
|
services.AddScoped<CartService>();
|
||||||
|
services.AddShopServices(includeLocalStorage: true);
|
||||||
|
services.AddHashServices(configuration);
|
||||||
|
services.AddPayfastServices(configuration);
|
||||||
|
|
||||||
|
services.AddDataProtectionDatabase(configuration);
|
||||||
|
services.AddMidrandShopDatabase(configuration);
|
||||||
|
|
||||||
|
services.AddSecurityApiSdk(configuration);
|
||||||
|
services.AddLiteCharmsWebSecurity(configuration);
|
||||||
|
|
||||||
|
services.AddMidrandShopPostgresHealthCheck();
|
||||||
|
services.AddMidrandShopQuartzHealthCheck();
|
||||||
|
services.AddHealthChecksSupport(configuration);
|
||||||
|
|
||||||
|
services.Configure<ForwardedHeadersOptions>(options =>
|
||||||
|
{
|
||||||
|
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||||
|
options.KnownProxies.Clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ metadata:
|
|||||||
namespace: midrandbooks-uat
|
namespace: midrandbooks-uat
|
||||||
data:
|
data:
|
||||||
ASPNETCORE_ENVIRONMENT: "Development"
|
ASPNETCORE_ENVIRONMENT: "Development"
|
||||||
ASPNETCORE_URLS: "https://0.0.0.0:8443"
|
ASPNETCORE_URLS: "http://0.0.0.0:8443"
|
||||||
Monitoring__Address: "http://aspire-dashboard-service.aspire.svc.cluster.local:18889"
|
Monitoring__Address: "http://aspire-dashboard-service.aspire.svc.cluster.local:18889"
|
||||||
Monitoring__ServiceName: "MidrandBooks.Uat"
|
Monitoring__ServiceName: "MidrandBooks.Uat"
|
||||||
HasherSettings__MinHashLength: "11"
|
HasherSettings__MinHashLength: "11"
|
||||||
@@ -194,14 +194,14 @@ spec:
|
|||||||
httpGet:
|
httpGet:
|
||||||
path: /health
|
path: /health
|
||||||
port: 8443
|
port: 8443
|
||||||
scheme: HTTPS
|
scheme: HTTP
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health
|
path: /health
|
||||||
port: 8443
|
port: 8443
|
||||||
scheme: HTTPS
|
scheme: HTTP
|
||||||
initialDelaySeconds: 3
|
initialDelaySeconds: 3
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
volumes:
|
volumes:
|
||||||
@@ -236,6 +236,7 @@ metadata:
|
|||||||
name: midrandbooks-web-secure
|
name: midrandbooks-web-secure
|
||||||
namespace: midrandbooks-uat
|
namespace: midrandbooks-uat
|
||||||
spec:
|
spec:
|
||||||
|
insecureSkipVerify: true
|
||||||
entryPoints:
|
entryPoints:
|
||||||
- websecure
|
- websecure
|
||||||
routes:
|
routes:
|
||||||
@@ -244,6 +245,6 @@ spec:
|
|||||||
services:
|
services:
|
||||||
- name: midrandbooks-service
|
- name: midrandbooks-service
|
||||||
port: 443
|
port: 443
|
||||||
scheme: https
|
scheme: http
|
||||||
serversTransport: midrandbooks-bypass-backend-validation
|
serversTransport: midrandbooks-bypass-backend-validation
|
||||||
tls: {}
|
tls: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user