Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44df489406 | |||
| 1bb1b0d476 | |||
| 0ea31a33ae | |||
| 0bb5da3513 | |||
| 4f44d0c597 | |||
| c3e6f9801b | |||
| fbde2ea1a9 | |||
| d323bd866c | |||
| 651682156c | |||
| a6a41eaeac | |||
| e81789f8c6 | |||
| 17a74ca750 | |||
| b9f3274633 | |||
| 53b3018d9e |
@@ -18,13 +18,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteCharms.Features" Version="1.131.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.131.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
-62
@@ -1,88 +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 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();
|
|
||||||
});
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.UseForwardedHeaders();
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": false,
|
"launchBrowser": false,
|
||||||
"applicationUrl": "https://localhost:7021;http://localhost:5053",
|
"applicationUrl": "https://localhost:8440;http://localhost:8083",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-20
@@ -10,8 +10,8 @@ metadata:
|
|||||||
name: midrandbooks-config
|
name: midrandbooks-config
|
||||||
namespace: midrandbooks-uat
|
namespace: midrandbooks-uat
|
||||||
data:
|
data:
|
||||||
ASPNETCORE_ENVIRONMENT: "Development"
|
ASPNETCORE_ENVIRONMENT: "Development"
|
||||||
ASPNETCORE_URLS: "http://0.0.0.0:8080"
|
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"
|
||||||
@@ -27,7 +27,6 @@ data:
|
|||||||
PayfastSettings__ValidHosts__4: "payment.payfast.io"
|
PayfastSettings__ValidHosts__4: "payment.payfast.io"
|
||||||
LiteCharmsSettings__Authority: "https://sts.security.khongisa.co.za"
|
LiteCharmsSettings__Authority: "https://sts.security.khongisa.co.za"
|
||||||
LiteCharmsSettings__Audience: "midrandbooks-api"
|
LiteCharmsSettings__Audience: "midrandbooks-api"
|
||||||
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
|
|
||||||
LiteCharmsClientSettings__Authority: "https://sts.security.khongisa.co.za"
|
LiteCharmsClientSettings__Authority: "https://sts.security.khongisa.co.za"
|
||||||
LiteCharmsClientSettings__GrantType: "client_credentials"
|
LiteCharmsClientSettings__GrantType: "client_credentials"
|
||||||
LiteCharmsClientSettings__Scope: "midrandbooks-api"
|
LiteCharmsClientSettings__Scope: "midrandbooks-api"
|
||||||
@@ -74,7 +73,7 @@ metadata:
|
|||||||
name: midrandbooks
|
name: midrandbooks
|
||||||
namespace: midrandbooks-uat
|
namespace: midrandbooks-uat
|
||||||
spec:
|
spec:
|
||||||
replicas: 2
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: midrandbooks
|
app: midrandbooks
|
||||||
@@ -102,7 +101,7 @@ spec:
|
|||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
cpu: "100m"
|
cpu: "100m"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8443
|
||||||
envFrom:
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: midrandbooks-config
|
name: midrandbooks-config
|
||||||
@@ -194,13 +193,15 @@ spec:
|
|||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health
|
path: /health
|
||||||
port: 8080
|
port: 8443
|
||||||
|
scheme: HTTP
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health
|
path: /health
|
||||||
port: 8080
|
port: 8443
|
||||||
|
scheme: HTTP
|
||||||
initialDelaySeconds: 3
|
initialDelaySeconds: 3
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
volumes:
|
volumes:
|
||||||
@@ -214,14 +215,20 @@ metadata:
|
|||||||
name: midrandbooks-service
|
name: midrandbooks-service
|
||||||
namespace: midrandbooks-uat
|
namespace: midrandbooks-uat
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
ports:
|
||||||
|
- name: https
|
||||||
|
port: 443
|
||||||
|
targetPort: 8443
|
||||||
selector:
|
selector:
|
||||||
app: midrandbooks
|
app: midrandbooks
|
||||||
ports:
|
---
|
||||||
- name: http
|
apiVersion: traefik.io/v1alpha1
|
||||||
protocol: TCP
|
kind: ServersTransport
|
||||||
port: 80
|
metadata:
|
||||||
targetPort: 8080
|
name: midrandbooks-bypass-backend-validation
|
||||||
|
namespace: midrandbooks-uat
|
||||||
|
spec:
|
||||||
|
insecureSkipVerify: true
|
||||||
---
|
---
|
||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
@@ -229,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:
|
||||||
@@ -236,10 +244,7 @@ spec:
|
|||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: midrandbooks-service
|
- name: midrandbooks-service
|
||||||
port: 80
|
port: 443
|
||||||
sticky:
|
scheme: http
|
||||||
cookie:
|
serversTransport: midrandbooks-bypass-backend-validation
|
||||||
name: "lp-sticky-session"
|
tls: {}
|
||||||
httpOnly: true
|
|
||||||
secure: true
|
|
||||||
tls: {}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user