This commit is contained in:
@@ -49,7 +49,7 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask<Result<bool>> ValidateReferrerIpAsync(string remoteIpAddress, CancellationToken cancellationToken = default)
|
||||
public async ValueTask<Result<bool>> ValidateReferrerIpAsync(string remoteIpAddress, bool allowLoopback = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(remoteIpAddress))
|
||||
return Result.Fail<bool>("Remote IP address is null or whitespace.");
|
||||
@@ -74,6 +74,12 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
|
||||
if (IPAddress.TryParse(remoteIpAddress, out var incomingIp))
|
||||
{
|
||||
if (allowLoopback && IPAddress.IsLoopback(incomingIp))
|
||||
{
|
||||
logger.LogInformation("Local development loopback IP '{RemoteIp}' allowed bypassing DNS verification.", remoteIpAddress);
|
||||
return Result.Ok(true);
|
||||
}
|
||||
|
||||
bool isValid = validIps.Contains(incomingIp);
|
||||
|
||||
if (!isValid)
|
||||
|
||||
Reference in New Issue
Block a user