Compare commits

..

56 Commits

Author SHA1 Message Date
khwezi a185fe5e80 Merge pull request 'Refactored docker build to use image caching' (#32) from update into master
Reviewed-on: #32
2026-06-16 10:38:17 +02:00
Khwezi Mngoma 24c8f81391 Refactored docker build to use image caching
continuous-integration/drone/pr Build is passing
2026-06-16 10:36:25 +02:00
khwezi d38272d58a Merge pull request 'Added automati revision history pruning' (#31) from update into master
Reviewed-on: #31
2026-06-15 23:28:31 +02:00
Khwezi Mngoma d219a7727f Added automati revision history pruning
continuous-integration/drone/pr Build is passing
2026-06-15 23:27:39 +02:00
khwezi 80f40cb99f Merge pull request 'Removed secrets from manifest, injecting them from predefined cluster secret in namespace' (#30) from update into master
Reviewed-on: #30
2026-06-15 23:05:56 +02:00
Khwezi Mngoma 8cdcaa55e9 Removed secrets from manifest, injecting them from predefined cluster secret in namespace
continuous-integration/drone/pr Build is passing
2026-06-15 23:05:22 +02:00
khwezi 66dd7c4b14 Merge pull request 'Updated nuget packages' (#29) from update into master
Reviewed-on: #29
2026-06-15 09:08:07 +02:00
Khwezi Mngoma 7125f5b909 Updated nuget packages
continuous-integration/drone/pr Build is passing
2026-06-15 09:06:23 +02:00
khwezi b7c30fbfb5 Merge pull request 'Updated nuget packages' (#28) from payments into master
Reviewed-on: #28
2026-06-13 21:27:40 +02:00
Khwezi Mngoma 6f913ce9d4 Updated nuget packages
continuous-integration/drone/pr Build is passing
2026-06-13 21:27:02 +02:00
khwezi 5c7ef3525f Merge pull request 'Refactored ledger handing' (#27) from payments into master
Reviewed-on: #27
2026-06-13 18:08:59 +02:00
Khwezi Mngoma 86da0d843e Refactored ledger handing
continuous-integration/drone/pr Build is passing
2026-06-13 18:08:34 +02:00
khwezi 59710e32a6 Merge pull request 'Updated nuget packages' (#26) from payments into master
Reviewed-on: #26
2026-06-13 17:22:56 +02:00
Khwezi Mngoma 5190fcaa17 Updated nuget packages
continuous-integration/drone/pr Build is passing
2026-06-13 17:22:26 +02:00
khwezi d0afc4f748 Merge pull request 'Updated niget packages' (#25) from payments into master
Reviewed-on: #25
2026-06-13 16:38:48 +02:00
Khwezi Mngoma 9a96c0ad0c Updated niget packages
continuous-integration/drone/pr Build is passing
2026-06-13 16:38:18 +02:00
khwezi 8cdfba58fd Merge pull request 'Refactored endpoint to handle incoming form using IFormCollection' (#24) from payments into master
Reviewed-on: #24
2026-06-13 16:10:33 +02:00
Khwezi Mngoma 41e1c9da4c Refactored endpoint to handle incoming form using IFormCollection
continuous-integration/drone/pr Build is passing
2026-06-13 16:10:05 +02:00
khwezi 01d3aa90ea Merge pull request 'Added inline logging for critical bugs' (#23) from payments into master
Reviewed-on: #23
2026-06-13 15:30:28 +02:00
Khwezi Mngoma c3981fd859 Added inline logging for critical bugs
continuous-integration/drone/pr Build is passing
2026-06-13 15:29:55 +02:00
khwezi 8cc4425dfb Merge pull request 'payments' (#22) from payments into master
Reviewed-on: #22
2026-06-13 13:14:50 +02:00
Khwezi Mngoma 60579c6230 Slowed down health check stream
continuous-integration/drone/pr Build is passing
2026-06-13 13:14:27 +02:00
Khwezi Mngoma f3478270fb Added logging to endpoint 2026-06-13 13:13:01 +02:00
khwezi 1039f6f2d5 Merge pull request 'Removed ipValidation checks' (#21) from payments into master
Reviewed-on: #21
2026-06-13 12:48:52 +02:00
Khwezi Mngoma 765eee2060 Removed ipValidation checks
continuous-integration/drone/pr Build is passing
2026-06-13 12:48:08 +02:00
khwezi ee250a18f0 Merge pull request 'Refactored valid payfast host list' (#20) from payments into master
Reviewed-on: #20
2026-06-13 12:12:26 +02:00
Khwezi Mngoma 5972f8906b Refactored valid payfast host list
continuous-integration/drone/pr Build is passing
2026-06-13 12:11:44 +02:00
khwezi b90c6381a0 Merge pull request 'Refactored manifest to use correct secrets' (#19) from payments into master
Reviewed-on: #19
2026-06-13 11:27:06 +02:00
Khwezi Mngoma c65398bdf6 Refactored manifest to use correct secrets
continuous-integration/drone/pr Build is passing
2026-06-13 11:26:43 +02:00
khwezi 2958ca8c00 Merge pull request 'Upgraded nuget librarief, refactored k8s manifest' (#18) from payments into master
Reviewed-on: #18
2026-06-13 11:12:27 +02:00
Khwezi Mngoma e546b3e7ff Upgraded nuget librarief, refactored k8s manifest
continuous-integration/drone/pr Build is passing
2026-06-13 11:11:50 +02:00
khwezi 1132ba0401 Merge pull request 'Added PayfastCheckoutEndpoint stub' (#17) from payments into master
Reviewed-on: #17
2026-06-12 09:02:34 +02:00
Khwezi Mngoma 5e119818bb Added PayfastCheckoutEndpoint stub
continuous-integration/drone/pr Build is passing
2026-06-12 09:01:39 +02:00
khwezi 181056d70d Merge pull request 'Audience validation achieved' (#16) from payments into master
Reviewed-on: #16
2026-06-07 00:04:00 +02:00
Khwezi Mngoma c01a02ee97 Audience validation achieved
continuous-integration/drone/pr Build is passing
2026-06-07 00:03:17 +02:00
khwezi dfb5ce8a4b Merge pull request 'Built test for Gomba' (#15) from payments into master
Reviewed-on: #15
2026-06-06 22:47:02 +02:00
Khwezi Mngoma 36b2f365d9 Built test for Gomba
continuous-integration/drone/pr Build is passing
2026-06-06 22:46:00 +02:00
khwezi 9bff28cec2 Merge pull request 'Updated api to use litecharms-security' (#14) from payments into master
Reviewed-on: #14
2026-06-06 22:09:10 +02:00
Khwezi Mngoma c76438b881 Updated api to use litecharms-security
continuous-integration/drone/pr Build is passing
2026-06-06 22:08:04 +02:00
khwezi 857173af25 Merge pull request 'Updated introspection configuration' (#13) from payments into master
Reviewed-on: #13
2026-06-05 06:03:52 +02:00
Khwezi Mngoma e29c1ef6fc Updated introspection configuration
continuous-integration/drone/pr Build is passing
2026-06-05 06:02:58 +02:00
khwezi c8a4a4cb17 Merge pull request 'Fixed setup issue' (#12) from payments into master
Reviewed-on: #12
2026-06-04 14:22:51 +02:00
Khwezi Mngoma 56e002875e Fixed setup issue
continuous-integration/drone/pr Build is passing
2026-06-04 14:22:22 +02:00
khwezi d485e78498 Merge pull request 'Updated auth configs' (#11) from payments into master
Reviewed-on: #11
2026-06-04 14:14:03 +02:00
Khwezi Mngoma ba3f8f6f9b Updated auth configs
continuous-integration/drone/pr Build is failing
2026-06-04 14:13:26 +02:00
khwezi 815470ab07 Merge pull request 'Mapped environment variables to secret keys' (#10) from payments into master
Reviewed-on: #10
2026-06-04 11:48:32 +02:00
Khwezi Mngoma 16a2516816 Mapped environment variables to secret keys
continuous-integration/drone/pr Build is passing
2026-06-04 11:47:42 +02:00
khwezi 8842d92b9b Merge pull request 'payments' (#9) from payments into master
Reviewed-on: #9
2026-06-04 09:09:16 +02:00
Khwezi Mngoma fc25d7ea40 Refactored k8s manifest
continuous-integration/drone/pr Build is passing
2026-06-04 09:08:36 +02:00
Khwezi Mngoma 8d8c1436f6 Applied authentik endpoint protection 2026-06-04 09:03:07 +02:00
khwezi 0c14872602 Merge pull request 'Refactored token input label' (#8) from payments into master
Reviewed-on: #8
2026-06-03 12:30:34 +02:00
Khwezi Mngoma d0ec655085 Refactored token input label
continuous-integration/drone/pr Build is passing
2026-06-03 12:29:38 +02:00
khwezi 3e23217eb4 Merge pull request 'payments' (#7) from payments into master
Reviewed-on: #7
2026-06-03 11:47:38 +02:00
Khwezi Mngoma 17d2ac409b Fixed namespacing
continuous-integration/drone/pr Build is passing
2026-06-03 11:46:44 +02:00
Khwezi Mngoma 2d5614c504 Updated nuget packages 2026-06-03 11:41:21 +02:00
Khwezi Mngoma 5bb7c4a959 Upgraded quartz 2026-06-03 11:16:58 +02:00
6 changed files with 63 additions and 100 deletions
+2
View File
@@ -31,6 +31,8 @@ steps:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/midrandbooks-api
tags: [ latest, "1.${DRONE_BUILD_NUMBER}" ]
use_cache: true
cache_from: nexus.khongisa.co.za/midrandbooks-api:latest
custom_labels:
- org.opencontainers.image.source=https://gitea.khongisa.co.za/litecharms/midrandbooks-api
- org.opencontainers.image.version=1.${DRONE_BUILD_NUMBER}
+8 -6
View File
@@ -14,8 +14,8 @@
<PackageReference Include="IdentityModel.AspNetCore.OAuth2introspection" Version="6.2.0" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="IdentityModel" Version="6.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="10.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="10.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
</ItemGroup>
<!-- Health Checks -->
@@ -39,8 +39,8 @@
<!-- API Documentation -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.8" />
<PackageReference Include="Scalar.AspNetCore" Version="2.14.14" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9" />
<PackageReference Include="Scalar.AspNetCore" Version="2.16.3" />
<Using Include="Scalar.AspNetCore" />
<Using Include="Microsoft.OpenApi" />
@@ -54,13 +54,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="LiteCharms.Features" Version="1.68.0" />
<PackageReference Include="LiteCharms.Features" Version="1.137.0" />
</ItemGroup>
<!-- UI -->
<ItemGroup>
<PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" />
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.68.0" />
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.137.0" />
<!-- Global Usings -->
<Using Include="Blazored.Toast.Services" />
@@ -89,6 +89,8 @@
<Using Include="System.Web" />
<Using Include="System.Diagnostics" />
<Using Include="System.Reflection" />
<Using Include="Microsoft.AspNetCore.Mvc" />
<Using Include="System.ComponentModel.DataAnnotations" />
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
</ItemGroup>
@@ -4,31 +4,25 @@ using LiteCharms.Features.Extensions;
using LiteCharms.Features.MidrandBooks.Payments;
using LiteCharms.Features.MidrandBooks.Payments.Events;
using LiteCharms.Features.MidrandBooks.Payments.Models;
using LiteCharms.Features.Quartz.Abstractions;
using static LiteCharms.Features.Extensions.Api;
namespace MidrandBooksApi.Payments.Endpoints;
namespace MidrandBooksApi.Payments.Payfast;
[ApiVersionTarget(1)]
public sealed class ConfirmationEndpoint : IEndpoint
public sealed class PayfastConfirmationEndpoint : IEndpoint
{
private static readonly ActivitySource PaymentActivitySource = new("MidrandBooksApi.Payments");
public void Map(IEndpointRouteBuilder builder)
{
builder.MapPost("payments/payfast/confirm", async (HttpRequest request, PayfastService payfastService,
IJobOrchestrator jobOrchestrator, IConfiguration configuration, IHostEnvironment hostEnvironment, CancellationToken cancellationToken) =>
IJobOrchestrator jobOrchestrator, IConfiguration configuration, IHostEnvironment hostEnvironment,
ILogger<PayfastConfirmationEndpoint> logger, CancellationToken cancellationToken) =>
{
using Activity? activity = PaymentActivitySource.StartActivity("ReceivePayfastWebhook", ActivityKind.Server);
activity?.SetTag("messaging.system", "payfast");
activity?.SetTag("messaging.destination.name", "payments/confirm");
string? remoteIp = request.HttpContext.Connection.RemoteIpAddress?.ToString();
var ipValidation = await payfastService.ValidateReferrerIpAsync(remoteIp!, !hostEnvironment.IsProduction(), cancellationToken);
if (ipValidation.IsFailed || !ipValidation.Value) return Results.Unauthorized();
activity?.SetTag("messaging.destination.name", "payments/payfast/confirm");
var formCollection = await request.ReadFormAsync(cancellationToken);
@@ -38,36 +32,42 @@ public sealed class ConfirmationEndpoint : IEndpoint
string incomingSignature = signatureValues.ToString().Trim();
var payload = ParseForm(formCollection, incomingSignature);
var paramDictionary = payload.ToParamDictionary();
string? passphrase = configuration["HasherSettings:PayfastPassphrase"];
string? passphrase = configuration["PayfastSettings:Passphrase"];
var signatureCheck = PayfastService.GenerateSignature(paramDictionary, passphrase);
if (!PayfastService.VerifyIncomingSignatureFromForm(formCollection, passphrase!))
{
logger.LogCritical($"Incoming signature failed validation: {incomingSignature}");
if (signatureCheck.IsFailed || !string.Equals(signatureCheck.Value, incomingSignature, StringComparison.OrdinalIgnoreCase))
return Results.Unauthorized();
}
var formPairs = formCollection.Select(kvp => $"{kvp.Key}={HttpUtility.UrlEncode(kvp.Value.ToString())}");
var sortedPairs = formCollection
.Where(kvp => !kvp.Key.Equals("signature", StringComparison.OrdinalIgnoreCase))
.OrderBy(kvp => kvp.Key, StringComparer.Ordinal)
.Select(kvp => $"{kvp.Key}={HttpUtility.UrlEncode(kvp.Value.ToString().Trim())}");
string rawQueryParamString = string.Join("&", formPairs);
string rawQueryParamString = string.Join("&", sortedPairs);
bool isSandbox = !hostEnvironment.IsProduction();
var serverConfirmation = await payfastService.ValidateServerConfirmationAsync(rawQueryParamString, isSandbox, cancellationToken);
if (serverConfirmation.IsFailed || !serverConfirmation.Value)
{
logger.LogCritical($"Payfast server validation ping rejected the request data: {rawQueryParamString}");
return Results.Unauthorized();
}
var notification = PayfastPaymentConfirmationReceivedEvent.Create(payload, payload.MerchantPaymentId!,
allowLoopback: !hostEnvironment.IsProduction(), performBackgroundChecks: false); // Set to false because comprehensive checks are completed inline above
allowLoopback: !hostEnvironment.IsProduction(), performBackgroundChecks: false);
await jobOrchestrator.SendAsync(notification, cancellationToken);
activity?.SetStatus(ActivityStatusCode.Ok);
return Results.Ok();
})
.WithDescription("Securely confirm and process an incoming Payfast merchant payment callback.")
.WithName(typeof(ConfirmationEndpoint).ToEndpointName())
.WithName(typeof(PayfastConfirmationEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces(StatusCodes.Status200OK)
.Produces(StatusCodes.Status400BadRequest)
+3 -3
View File
@@ -11,10 +11,8 @@ builder.Services.AddEndpointsApiExplorer();
builder.Services.AddEndpoints(Assembly.GetExecutingAssembly());
builder.Services.AddApiServices(builder.Configuration);
builder.Services.AddAuthorization();
builder.Services.AddAuthentication();
builder.Services.AddMediator();
builder.Services.AddLiteCharmsApiSecurity(builder.Configuration);
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
@@ -24,7 +22,9 @@ builder.Services.AddQuartzSchedulerClient(MidrandShopSchedulerName, builder.Conf
builder.Services.AddEmailServices(builder.Configuration);
builder.Services.AddEmailServiceBus();
builder.Services.AddHttpClient();
builder.Services.AddShopServices();
builder.Services.AddPayfastServices(builder.Configuration);
builder.Services.AddHashServices(builder.Configuration);
builder.Services.AddMidrandShopDatabase(builder.Configuration);
+16 -10
View File
@@ -1,13 +1,20 @@
{
"ValidPayfastHosts": [
"www.payfast.co.za",
"sandbox.payfast.co.za",
"w1w.payfast.co.za",
"w2w.payfast.co.za",
"ips.payfast.co.za",
"api.payfast.co.za",
"payment.payfast.io"
],
"PayfastSettings": {
"CheckoutUrl": "https://sandbox.payfast.co.za/eng/process",
"ValidHosts": [
"www.payfast.co.za",
"sandbox.payfast.co.za",
"w1w.payfast.co.za",
"w2w.payfast.co.za",
"ips.payfast.co.za",
"api.payfast.co.za",
"payment.payfast.io"
]
},
"LiteCharmsSettings": {
"Authority": "https://sts.security.khongisa.co.za",
"Audience": "midrandbooks-api"
},
"HasherSettings": {
"MinHashLength": 11
},
@@ -18,7 +25,6 @@
"CdnBaseUrl": "https://bookshop.cdn.khongisa.co.za"
},
"Monitoring": {
"ApiKey": "",
"Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889",
"ServiceName": "MidrandBooks.DEV"
},
+13 -60
View File
@@ -19,28 +19,14 @@ data:
BookshopS3Settings__Region: "garage"
BookshopS3Settings__BucketName: "bookshop"
BookshopS3Settings__CdnBaseUrl: "https://bookshop.cdn.khongisa.co.za"
ValidPayfastHosts__0: "www.payfast.co.za"
ValidPayfastHosts__1: "sandbox.payfast.co.za"
ValidPayfastHosts__2: "w1w.payfast.co.za"
ValidPayfastHosts__3: "w2w.payfast.co.za"
ValidPayfastHosts__4: "ips.payfast.co.za"
ValidPayfastHosts__5: "api.payfast.co.za"
ValidPayfastHosts__6: "payment.payfast.io"
---
apiVersion: v1
kind: Secret
metadata:
name: midrandbooksapi-secrets
namespace: midrandbooksapi-uat
type: Opaque
data:
connection-string: SG9zdD0xOTIuMTY4LjEuMTcwO0RhdGFiYXNlPW1pZHJhbmRzaG9wLWRldjtVc2VybmFtZT1taWRyYW5kc2hvcC1kZXYtdXNlcjtQYXNzd29yZD1hUFh5a0tnM3RTOWNtRDtQZXJzaXN0IFNlY3VyaXR5IEluZm89VHJ1ZQ==
connection-string-quartz: SG9zdD0xOTIuMTY4LjEuMTcwO0RhdGFiYXNlPXNjaGVkdWxlci1kZXY7VXNlcm5hbWU9c2NoZWR1bGVyLWRldi11c2VyO1Bhc3N3b3JkPWtWVm1vV0tKM3h6Z1FYO1BlcnNpc3QgU2VjdXJpdHkgSW5mbz1UcnVl
aspire-apikey: bWMzRzYzSzJqNVpPRXNpMEFqTW9qTFRYbTFLRVpGY3R6SUlqU3dEaVRHdXQ4cUdTa1B1V3d4R1AxUmJzY0pVbw==
hasher-salt: VEdsbmFIUWdRMmhoY20xekxDQk5hV1J5WVc1a1FtOXZhM01nYldGclpTQnNiM1J6SUc5bUlHMXZibVY1SUdGdVpDQmhjbVVnWVNCemRXTmpaWE56Wm5Wc0lIWnBjbUZzSUhOMGIzSjVJR2x1SUZOdmRYUm9JRUZtY21sallRPT0=
hasher-payfastpassphrase: OUdBSVIwdFdwaFgwcU8=
bookshop-s3-accesskey: R0s1MTRkMmNlOGRjNjkyMzdhMDVjMDFlZWY=
bookshop-s3-secretkey: ZWFhZmVkYTFhZWQ0MDllY2ZlNjA3MTRlY2RhNTQ5YjgyYmRmNWEzZGFmOWYxOGRkNjFmNjZiNDk3M2E2NDgyZQ==
PayfastSettings__CheckoutUrl: "https://sandbox.payfast.co.za/eng/process"
PayfastSettings__ValidHosts__0: "www.payfast.co.za"
PayfastSettings__ValidHosts__1: "sandbox.payfast.co.za"
PayfastSettings__ValidHosts__2: "ips.payfast.co.za"
PayfastSettings__ValidHosts__3: "api.payfast.co.za"
PayfastSettings__ValidHosts__4: "payment.payfast.io"
LiteCharmsSettings__Authority: "https://sts.security.khongisa.co.za"
LiteCharmsSettings__Audience: "midrandbooks-api"
---
apiVersion: v1
kind: PersistentVolumeClaim
@@ -61,6 +47,7 @@ metadata:
namespace: midrandbooksapi-uat
spec:
replicas: 2
revisionHistoryLimit: 0
selector:
matchLabels:
app: midrandbooks-api
@@ -92,42 +79,8 @@ spec:
envFrom:
- configMapRef:
name: midrandbooksapi-config
env:
- name: BookshopS3Settings__AccessKey
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: bookshop-s3-accesskey
- name: BookshopS3Settings__SecretKey
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: bookshop-s3-secretkey
- name: HasherSettings__Salt
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: hasher-salt
- name: HasherSettings__PayfastPassphrase
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: hasher-payfastpassphrase
- name: ConnectionStrings__PostgresScheduler
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: connection-string-quartz
- name: ConnectionStrings__PostgresMidrandBooks
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: connection-string
- name: Monitoring__ApiKey
valueFrom:
secretKeyRef:
name: midrandbooksapi-secrets
key: aspire-apikey
- secretRef:
name: midrandbooksapi-secrets
volumeMounts:
- name: data
mountPath: /app/wwwroot/content
@@ -136,8 +89,8 @@ spec:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
initialDelaySeconds: 10
periodSeconds: 15
readinessProbe:
httpGet:
path: /health