Skip to content

Commit

Permalink
no response event was added (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
apashkov-ext authored Jun 13, 2023
1 parent 15306a7 commit 1677600
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<PacketCode> ProcessRadiusAuthentication(PendingRequest request
if (response == null)
{
_logger.Warning("Remote Radius Server did not respond on message with id={id}", request.RequestPacket.Identifier);
return PacketCode.AccessReject; //reject by default
return PacketCode.DisconnectNak;
}

var responsePacket = _packetParser.Parse(response, request.RequestPacket.SharedSecret, request.RequestPacket.Authenticator);
Expand Down
7 changes: 7 additions & 0 deletions MultiFactor.Radius.Adapter/Server/RadiusRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class RadiusRouter
private ILogger _logger;
private MultiFactorApiClient _multifactorApiClient;
public event EventHandler<PendingRequest> RequestProcessed;
public event EventHandler<PendingRequest> RequestWillNotBeProcessed;
private readonly ConcurrentDictionary<string, PendingRequest> _stateChallengePendingRequests = new ConcurrentDictionary<string, PendingRequest>();
private PasswordChangeHandler _passwordChangeHandler;
private readonly FirstAuthFactorProcessorProvider _firstAuthFactorProcessorProvider;
Expand Down Expand Up @@ -87,6 +88,12 @@ public async Task HandleRequest(PendingRequest request, ClientConfiguration clie

var firstAuthFactorProcessor = _firstAuthFactorProcessorProvider.GetProcessor(clientConfig.FirstFactorAuthenticationSource);
var firstFactorAuthenticationResultCode = await firstAuthFactorProcessor.ProcessFirstAuthFactorAsync(request, clientConfig);
if (firstFactorAuthenticationResultCode == PacketCode.DisconnectNak)
{
RequestWillNotBeProcessed?.Invoke(this, request);
return;
}

if (firstFactorAuthenticationResultCode != PacketCode.AccessAccept)
{
//User password expired ot must be changed
Expand Down
4 changes: 4 additions & 0 deletions MultiFactor.Radius.Adapter/Server/RadiusServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void Start()
var receiveTask = Receive();

_radiusRouter.RequestProcessed += RouterRequestProcessed;
_radiusRouter.RequestWillNotBeProcessed += RouterRequestWillNotBeProcessed;

_logger.Information("Server started");
}
Expand All @@ -114,6 +115,7 @@ public void Stop()
Running = false;
_server?.Close();
_radiusRouter.RequestProcessed -= RouterRequestProcessed;
_radiusRouter.RequestWillNotBeProcessed -= RouterRequestWillNotBeProcessed;
_logger.Information("Stopped");
}
else
Expand Down Expand Up @@ -390,6 +392,8 @@ private async void RouterRequestProcessed(object sender, PendingRequest request)
Send(responsePacket, request.RequestPacket?.UserName, request.RemoteEndpoint, request.ProxyEndpoint, debugLog);
}

private void RouterRequestWillNotBeProcessed(object sender, PendingRequest request) { }

private void AddCustomReplyAttributes(PendingRequest request, IRadiusPacket responsePacket, ClientConfiguration clientConfiguration)
{
foreach (var attr in clientConfiguration.RadiusReplyAttributes)
Expand Down

0 comments on commit 1677600

Please sign in to comment.